GithubHelp home page GithubHelp logo

memtrip / sqlking Goto Github PK

View Code? Open in Web Editor NEW
21.0 21.0 9.0 211 KB

SQLKing is an Android SQLite ORM powered by an annotation preprocessor, tables are defined by Table annotations and CRUD classes expose an expressive api for executing SQLite queries. @memtrip

License: Other

Java 100.00%

sqlking's People

Contributors

samkirton avatar trellian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

sqlking's Issues

How to do join queries?

Hi Sam,

Have you got a simple example of a query involving a join between two tables?

Thanks,
Adrian

Unable to locate the 'Q' class

Hi Sam,

Everything is resolving, except for the Q class. Can you give me a quick rundown of what I should do to configure this?

Also, I had to add
compile 'com.memtrip.sqlking:common:1.0.4'" to my build.gradle, alongside
apt 'com.memtrip.sqlking:preprocessor:1.0.4' and
compile 'com.memtrip.sqlking:client:1.0.5'

Thanks!

Unable to get android-apt to work with Android Studio 1.5 or 2.0, gradle rev 2.8

Hi,

I've just tried to update to the new version of SQLKing. It is completely different from the first version, and has several dependencies. One of them is the android-apt plugin, but I can't get gradle to recognise 'apt'.

Have you perhaps got a small demo project that implements a full SQLKing example?

Thanks in advance,
Adrian

Request for ability to ignore private static member variables in a Table

Hi Sam,

I would like to be able to either ignore static members, or specifically to ignore one called "CREATOR".

This would allow for adding parcelable implementation to a Table.

Would this be possible?

I think it could be done without too much trouble, as follows in Column.Java:

`
private List assembleMembers(Element element) {
List columns = new ArrayList<>();

    if (element.getEnclosedElements() != null && element.getEnclosedElements().size() > 0) {
        for (Element childElement : element.getEnclosedElements()) {
            if (childElement.getKind().isField()) {
                **if (!childElement.getSimpleName().toString().equals("CREATOR")) {**
                    columns.add(new Column(childElement));
                }
            }
        }
    }

    return columns;
}`

Q.java is being generated, but not found

Hi Sam,

Q.java is being generated, but I can't seem to import it or get my app to see it. I'm using my local repository (with some changes). Common and Preprocessor are building and installing, as does the client (I have set the version on all modules to 1.1.2)

This is new behaviour, possibly prompted by recent updates to my Android Studio.

Do you have any suggestions?

Regards,
Adrian

Foreign Key annotation syntax

Hi Sam, thanks a mill for the 1.0.6 release. I have a new problem now:

in one of my tables, I have the following:

`@Table
public class TblMapVisitor2Entry extends ScanTableBase implements Parcelable
{

@Column(index = true, foreign_key = "TblEntry")
private int     entry_fk;
@Column private int entry_reason;   // E_ENTRY_REASON

`
and it generates the following error:

error: [A @column with a foreign_key can only annotate a variable whose data type is annotated with @table]

What is the correct way to do this? Please note, that all of my tables extend from ScanTableBase, which looks like this:

`@Table
public class ScanTableBase
{
// Fields common to all tables
@column protected int id;
@column protected int synch_status;

@Column protected long        synch_date;       // Last good synch date
@Column protected boolean     deleted;
...
 }

`
Perhaps this is rocking the boat a bit?

Thanks,
Adrian

nullPointerException in Column.assembleIsIndex()

Hi Sam,

I'm getting the following error, and I can't see what is causing it, have you got any thoughts on this?

Caused by: java.lang.NullPointerException
at com.memtrip.sqlking.preprocessor.processor.model.Column.assembleIsIndex(Column.java:60)
at com.memtrip.sqlking.preprocessor.processor.model.Column.(Column.java:42)
at com.memtrip.sqlking.preprocessor.processor.model.Table.assembleMembers(Table.java:57)
at com.memtrip.sqlking.preprocessor.processor.model.Table.(Table.java:37)
at com.memtrip.sqlking.preprocessor.processor.model.Data.assembleTables(Data.java:24)
at com.memtrip.sqlking.preprocessor.processor.model.Data.(Data.java:16)
at com.memtrip.sqlking.preprocessor.processor.Processor.process(Processor.java:40)

Also, please can you give tell me what the annotation syntax is for setting up foreign keys and indexes?

Thanks,
Adrian

Retrieving columns from related tables with Joins

Hi Sam,

Is it possible to retrieve columns from tables that have been joined? Looking at the examples in the tests, it seems that only the root table columnset is returned.

eg. below, the return is of Class User, I can't see how to retrieve the Log columns.

        User[] users = Select .getBuilder()
                .join(innerJoin(Log.class, on("User.logId", "Log.id")))
                .execute(User.class, getSQLProvider());

Thanks,
Adrian

Error in client/build.gradle - requesting old version of preprocessor

Hi Sam,

While trying to install the client locally (for release 1.1), I discovered the following in the client/build.gradle:

androidTestApt 'com.memtrip.sqlking:preprocessor:1.0.17'

After changing the version:

androidTestApt 'com.memtrip.sqlking:preprocessor:1.1'

The client now successfully builds.

JTYSK ;)
Adrian

Recursive joins and lists - possible?

Hi Sam,

I've tried to model a 1-Many relationship, where I query a parent table joined to a child table, and expect to get a list or array of the child table returned as an object in the parent table record, but SQLKing does not support that yet.

Similar to that, where I have a self-referential table implementing a recursive hierarchy (which obviously also needs to return a list or array of it's own table type as a child, in the parent object.

Any chance of adding that soon?

Thanks,
Adrian

build of INNER join SQL text is missing whitespace

Hi Sam,

I'm getting an error on trying to execute a query with some nested joins. An SQLite exception is thrown as follows:

ERR: exMsg=no such column: TblMapVisitor2Entry.visitor_idINNER (code 1): ,
 while compiling: SELECT TblEntry.id,
 TblEntry.synch_status,
 TblEntry.synch_date,
.. (omitted for clarity).

The query code is:

        TblEntry[] entries =
            Select.getBuilder()
                .join (
                        innerJoin (
                                TblMapVisitor2Entry.class,
                                innerJoin (
                                          TblVisitor.class,
                                          on("TblVisitor.id", "TblMapVisitor2Entry.visitor_id"
                                          )
                                ),
                                on("TblMapVisitor2Entry.entry_id", "TblEntry.id")
                               ),
                      innerJoin (
                                TblMapVehicle2Entry.class,
                                innerJoin (
                                          TblVehicle.class,
                                          on("TblVehicle.id", "TblMapVehicle2Entry.visitor_id")
                                          )
                                )
                     )
                .orderBy(Q.TblEntry.ENTRY_DATE, OrderBy.Order.DESC)
                .limit(1, 10)
                .execute(TblEntry.class, ScanDB.sqlProvider);

It looks like a simple case of the INNER clause just not getting some whitespace in front of it. Can you help here?

Thanks,
Adrian

Duplicate definitions being generated in retrieveSQLSelectResults

Hi Sam,

I have a table that has two FK's in it as follows:

public class TblMapVisitor2Entry extends BaseObservable implements Parcelable
    {
    @Column(index = true) private int       id;
    @Column private TblEntry   tblEntry;
    @Column private TblVisitor tblVisitor;

and in Q.Java, I get an error on duplicate symbols as follows:

      for (int i = 0; !cursor.isAfterLast(); i++) {
        com.thorburn.sanscan.scanDB.TblMapVisitor2Entry tblmapvisitor2entry =
            new com.thorburn.sanscan.scanDB.TblMapVisitor2Entry();

        com.thorburn.sanscan.scanDB.TblEntry tblentry = new com.thorburn.sanscan.scanDB.TblEntry();
        tblmapvisitor2entry.setTblEntry(tblentry);

        com.thorburn.sanscan.scanDB.TblVisitor tblvisitor =
            new com.thorburn.sanscan.scanDB.TblVisitor();
        tblmapvisitor2entry.setTblVisitor(tblvisitor);

        com.thorburn.sanscan.scanDB.TblEntry tblentry = new com.thorburn.sanscan.scanDB.TblEntry();
        tblmapvisitor2entry.setTblEntry(tblentry);

        com.thorburn.sanscan.scanDB.TblVisitor tblvisitor =
            new com.thorburn.sanscan.scanDB.TblVisitor();
        tblmapvisitor2entry.setTblVisitor(tblvisitor);

You can see that 'tblentry' and 'tblvisitor' variables are being declared twice. I have had a look at the preprocessor template source for Q.Java but can't see how it could be happening. I'm currently taking a shot at fixing it, but not having much success.

Please can you take a look?

Thanks,
Adrian

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.