Sqldelight: Use of SqlDelightStatement with SQLBrite

Created on 28 Oct 2016  路  3Comments  路  Source: cashapp/sqldelight

Hi, I am using wrapper for SqlBrite for DAO objects - https://github.com/sockeqwe/sqlbrite-dao and this library creates its own SQLiteOpenHelper that is provided to SqlBrite. I dont have access to this helper and neither to SQLiteDatabase object and I cannot therefore create instance of generated SqlDelightCompiledStatement.Insert because it accepts SQLiteDatabase in constructor. Is there any way how to use only BriteDatabase instance and perform compiled inserts etc.? I looked at the example but this project does not have SqlBrite dependency and SqlBrite does not have dependency for SqlDelight (for obvious reason).

I saw that SqlBrite in the latest version supports execution of compiled statements but I dont really know how to get this statement without using deprecated API of SqlDelight

Most helpful comment

SQLBrite now exposes getWritableDatabase and getReadableDatabase in version 1.1.0 which can be passed to SQLDelight compiled statement constructors :+1:

All 3 comments

I would continue to use the deprecated API's for now since I don't think you have a choice and urge sqlbrite-dao to expose some method to compile statements since you're losing efficiency otherwise. That might be unlikely since they've probably explicitly hidden the db to get rid of any leaky abstraction - that's essentially what we're doing but in the opposite direction where we abstract over sqlite strings instead of the db.

And yea unfortunately there's no dependency between SQLBrite and SQLDelight so we can't use the OpenHelper that SQLBrite wraps.

SQLBrite now exposes getWritableDatabase and getReadableDatabase in version 1.1.0 which can be passed to SQLDelight compiled statement constructors :+1:

Fantastic! Thanks Alec!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

headsvk picture headsvk  路  3Comments

Nishant-Pathak picture Nishant-Pathak  路  3Comments

Nimrodda picture Nimrodda  路  4Comments

aegis123 picture aegis123  路  4Comments

LouisCAD picture LouisCAD  路  5Comments