Questions tagged [sqldelight]

SQLDelight generates Java models from your SQL statements. These models give you a typesafe API to read & write the rows of your tables. It helps you to keep your SQL statements together, organized, and easy to access from Java.

SQLDelight generates typesafe APIs from your SQL statements. It compile-time verifies your schema, statements, and migrations and provides IDE features like autocomplete and refactoring which make writing and maintaining SQL simple. SQLDelight currently supports the SQLite dialect and there are supported SQLite drivers on Android, JVM and iOS.

The premise of SQLDelight is unchanged: Write SQLite and let the Gradle plugin generate APIs to run your queries for you. SQLDelight files use the .sq extensions and are contained in your src/main/sqldelight folder in a Gradle module.

122 questions
5
votes
2 answers

How to use Sqldelight with Kotlin Coroutines

There are apparently Kotlin coroutines extension functions for SqlDelight, but I don't know how to implement them since I can't find documentation. I have a normal query that looks like this: val allItems get() =…
Jacques.S
  • 3,262
  • 2
  • 21
  • 27
4
votes
0 answers

Kotlin collections for SQLDelight file are not importing (KMM)

In my KMM project I'm using SQLdelight. My sample table has a List. Table: CREATE TABLE profile ( nikName TEXT, secretKey TEXT, description TEXT, tagList TEXT AS List ); According to documentation I created adapter: //TODO we cant use comas…
Dmitry
  • 130
  • 6
4
votes
2 answers

java.lang.IllegalStateException when collecting flow from SqlDelight in ViewModel

I am trying to use SqlDelight database in my app. In my DAO, I have a function called getRecipeById to query the database and return a flow of domain model (Recipe). Here is the implementation of the function: (Note: RecipeTable is the name of the…
4
votes
4 answers

How to Write Unit Tests for SQLDelight on KMM

I'm wondering how to write unit tests for SQLDelight on KMM. First of all, I can't even add the SQLDelight dependency correctly. val commonTest by getting { dependencies { implementation(kotlin("test-common")) …
4
votes
1 answer

Can I use sqldelight with different databases in same project?

I want to use SQLDelight to connect to a SQLite In-Memory database for test and to PostgreSQL server for production, is that use case possible? how I can do the config? and do I need to have .sq files for each database?
alilosoft
  • 301
  • 1
  • 8
4
votes
6 answers

Could not resolve com.squareup.sqldelight:runtime:1.1.3

I tried to integrate sqldelight in my Multiplatform library project for Android/iOS but I'm having several unresolved dependency errors when syncing gradle. ERROR: Unable to resolve dependency for ':SharedCode@debug/compileClasspath': Could not…
Alan
  • 1,264
  • 1
  • 11
  • 21
3
votes
1 answer

SQL Delight Plugin is not found in Android Studio Dolphin | 2021.3.1 Patch 1

SQL Delight Plugin is not found in Android Studio Dolphin | 2021.3.1 Patch 1. It is not a critical issue for me but I would like to know. I visited JetBrains website but it seems there is no compatibility with the Dolphin Version. I search in the…
3
votes
0 answers

How to use SQL Delight in android Electrical Eel?Connecting with the SQLdelight plugin failed

I updated android studio to the electric eel but after that I am unable to use SQLDelight plugin. It was showing me this :- Not compatible with the version of your running IDE (Android Studio Electric Eel | 2022.1.1) Then after that I downloaded EAP…
CHETAN
  • 380
  • 1
  • 3
  • 15
3
votes
1 answer

"Unresolved reference" error in SqlDelight

I have simple query in kotlin multiplatform project with SqlDelight database: getLast: SELECT * FROM history ORDER BY id DESC LIMIT ?; But when I try to build the app, I get such error ".....DatabaseImpl.kt: (207, 72): Unresolved reference:…
Alexander
  • 31
  • 2
3
votes
0 answers

How do we just recreate the database when I modify tables in sqldelight on Android

I was just trying out Sqldelight on Android but can't seem to figure out an easy way to just drop and recreate the db on device when I've modified a table (or even added / deleted a new table). The docs seems to indicate we need to create a…
Bootstrapper
  • 1,089
  • 3
  • 14
  • 33
3
votes
0 answers

Combine multiple flows and emit when any flows changes

I'm having some trouble understanding why the flow isn't working as expected in my app. There is three flows in total. The first two flows represents each a single value that can be changed by the user. They are saved with multiplatform-settings and…
Isak
  • 548
  • 2
  • 5
  • 20
3
votes
1 answer

Can I create an in-memory database with SqlDelight for running in Android?

I have a SqlDelight database that is working nicely. I create it like this: Database(AndroidSqliteDriver(Database.Schema, context, DatabaseName) For unit-tests, I create an in-memory database like…
Jacques.S
  • 3,262
  • 2
  • 21
  • 27
3
votes
1 answer

kotlinx.serialization.SerializationException: Serializer for class 'UnitEntity' (myClassName) is not found

I'm working on a Kotlin Multi-platform project and got a problem of saving database entity object. when I call insert method of my sqldelight dao classes exception where thrown kotlinx.serialization.SerializationException: Serializer for class…
3
votes
1 answer

Queries not generated from migration

I am using sqldelight 1.4.1 on Android. If I want to add tables in the second iteration of my app, where do I put the CREATE TABLE Preset(blabla) code? If I put it in 1.sqm, no queries are generated, only fun migrate(...) code is generated. There is…
Arneball
  • 359
  • 3
  • 10
3
votes
1 answer

ALTER TABLE migrations does not update the generated code

I'm writing a migration file which alters a table, adding a new column, but the generated code isn't updated, so I can't insert new records into the table with value to the new column. Example: // BankAccount.sq file CREATE TABLE bank_account…
1
2
3
8 9