anboralabs / spatia-room

Implementation of spatia lite database to android component Room
MIT License
41 stars 4 forks source link

Add support for in-memory database #34

Closed johan12345 closed 1 year ago

johan12345 commented 1 year ago

E.g. for unit testing purposes it is often useful to be able to create an in-memory database with Room.inMemoryDatabaseBuilder. This PR adds a corresponding SpatiaRoom.inMemoryDatabaseBuilder function for doing the same with spatia-room.

Apparently in-memory databases cannot be created from an asset, so I needed to remove createFromAsset(templateDb) call and the spatia_db_template.sqlite file. Instead, I added a callback that calls SELECT InitSpatialMetaData(); to initialize the database, which should have the same effect (right?) and also removes the need for shipping this extra 5 MB file with the app.

dalgarins commented 1 year ago

Hi @johan12345 this is great, I'm going to test it.

dalgarins commented 1 year ago

I'll let you know when the release has this changes.

dalgarins commented 1 year ago

@johan12345 here is the new version:

implementation 'com.github.anboralabs:spatia-room:0.2.6'

johan12345 commented 1 year ago

Awesome, thanks!