Comments (6)
For select statements there's the @Where
annotation.
@Where(path = "mypath")
public static String[] dynamicWhere() {
return new String[] {
MyColumns.COLUMN + ">" + util.getCurrentTime(),
};
}
This is called every time the "mypath" uri is queried.
Does that solve your problem?
from schematic.
Hello @SimonVT and thanks for your promptly response. Isn't the @Where
you suggested the same as using the where
from @InexactContentUri
? (Since it accepts an array).
Look, here are some queries I can't replicate with schematic right now:
SELECT shows.id, episodes.season, episodes.number, min(episodes.sortKey) as minKey, innerJoin.airedCount
FROM shows, episodes
LEFT JOIN (SELECT episodes.showId as showId, episodes.season as season, COUNT(*) as airedCount
FROM episodes
WHERE episodes.first_aired IS NOT NULL AND episodes.first_aired <= util.getCurrentTime()
GROUP BY episodes.showId, episodes.season)
AS innerJoin ON episodes.showId = innerJoin.showId AND episodes.season = innerJoin.season
WHERE episodes.showId = shows.id AND episodes.first_aired IS NOT NULL AND watched = 0
AND episodes.first_aired <= util.getCurrentTime()
GROUP BY shows.id
As you can see, I use the util.getCurrentTime() twice (for the outer where and inside the select of the LEFT JOIN). For the outer, no problem, @InexactContentUri
and passing it through the code that queries the ContentResolver. The problem is inside the LEFT JOIN.
Another example:
SELECT episodes.showId, episodes.season, COUNT(*) as allEpisodes, watchedEpisodes, airedEpisodes
FROM episodes
LEFT JOIN
(SELECT episodes.showId as notWatchedShowId, episodes.season as episodeSeasonNotWatched, COUNT(*) as watchedEpisodes FROM episodes WHERE episodes.watched = passedShowId AND episodes.showId=1 GROUP BY episodes.season)
as notWatched ON episodes.season = episodeSeasonNotWatched
LEFT JOIN
(SELECT episodes.showId as notAiredShowId, episodes.season as episodeSeasonNotAired, COUNT(*) as airedEpisodes FROM episodes WHERE episodes.showId =passedShowId AND episodes.first_aired IS NOT NULL GROUP BY episodes.season)
as notAired ON episodes.season = episodeSeasonNotAired
WHERE episodes.showId = passedShowId
GROUP BY episodes.season
Here I need a passedShowId in the outer where
but also inside the subqueries from the LEFT JOIN.
In both cases, I can't find a way of doing that using @InexactContentUri
. Hope that clarifies my problem.
Not sure about a solution but... What about a way of passing parameters to inners queries? Would that be possible?
from schematic.
No, there where
parameter for @ContentUri
and @InexactContentUri
are for static where statements. The method annotated with @Where
is called every time the Uri
is queried.
For joins there is currently no solution. A @Join
annotation would need to be added and called for every query.
from schematic.
I see... Those SELECT
into the join
(s) are petty common... Do you think/plan to add that @Join
annotation? I think it'd be a key feature.
from schematic.
Added a @Join
annotation in version 0.6.6. Annotate a method and return a String[] of join statements.
from schematic.
Version 0.6.7 now, I messed up regular joins in 0.6.6.
from schematic.
Related Issues (20)
- Add support for check, foreign key and primary key on table level. HOT 1
- Write the changelog in the GitHub releases
- Migrate from Apt to AnnotationProcessor HOT 4
- App crashes when trying to redeploy HOT 5
- Observation on placement of the database class
- NullPointerException on build when adding new Table HOT 1
- Create dropped tables again HOT 4
- Limit with Parameter HOT 1
- Join example
- Latest Version HOT 1
- java.lang.NullPointerException with no clue when using schematic 0.7.0 in SDK 26 and using annotationProcessor library. HOT 5
- When is onupgrade called in database HOT 2
- Unable to include repository with gradle
- Generated class not found on dexpathlist , Android Studio 3.0 HOT 1
- @InexactContentUri with String value HOT 4
- using where to add LIKE statement HOT 1
- Package net.simonvt.schematic.utils does not exist HOT 8
- How to use path value in WHERE clause?
- Unable to get provider error HOT 3
- How to validate content values before insertion or update?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from schematic.