vals-productions/sqlighter

Improvement: TypeSafe Wrapper for Insert und Update Query

Closed this issue · 7 comments

I made a wrapper for insert and update so far.

If you like it you can integrate it in your code or make improvements.

You find it here: https://gist.github.com/confile/a8f74bf355e22b052f47

Looking forward for your comments.

Here are the translations from your examles:

            SQLighterRs rs = new DBQueryBuilder(db)
                .select("id, email, name, data, height")
                .from("user")
                .build();

            new DBQueryBuilder(db).insertInto("user")
                .bindParam("name","user name 6")
                .bindParam("email","qw@er.ty1")
                .bindParam("data", data)
                .bindParam("height", "5.67")
                .build();

            new DBQueryBuilder(db)
                .update("user")
                .bindParamToNull("email")
                .where()
                .bindWhereParam("email", "qw@er.ty1")
                .build();

            rs = new DBQueryBuilder(db)
                .select("id, email, name, data, height")
                .from("user")
                .build();

            new DBQueryBuilder(db)
                .deleteFrom("user")
                .bindWhereParam("id", 2)
                .build();

            rs = new DBQueryBuilder(db)
                .select("id, email, name, data, height")
                .from("user")
                .build();

            new DBQueryBuilder(db)
                .createTable("address")
                .addColumn("id","integer primary key autoincrement unique")
                .addColumn("name", "text")
                .addColumn("user_id", "integer")
                .build();

            new DBQueryBuilder(db)
                .insertInto("address")
                .bindParam("name","123 main str, walnut creek, ca")
                .bindParam("user_id",1)
                .build();


            rs = new DBQueryBuilder(db)
                .select("a.user_id, u.email, u.name, u.data, u.height, a.name")
                .from("user u, address a")
                .bindWhereParam("a.user_id = u.id")
                .build();


@vals-productions You see this is much more save against run time errors in your queries.

@confile , I have similar wrapper for my java projects and there's bunch of them available as well. They, probably, should be distributed separately as they have wider usage than just one particular library.

Where can I find your wrapper?

Or do you mean there are other wrappers out there. Could you please link one.

The wrapper should be translatable with j2objc as well.

There's search function on github. This one, for instance, looks very like yours https://github.com/alexfu/SQLiteQueryBuilder