Comments (5)
The issue could be reproduced inside the sample using the following query:
@Query("SELECT * FROM BackPackEntity WHERE(:studentIds IS NULL OR studentId IN :studentIds)")
suspend fun getStudentBackPacks(
studentIds: List<String>?
): Flow<List<BackPackEntity>>
The generated code looks like this:
override fun <R> execute(mapper: SqlCursor.() -> QueryResult<R>): QueryResult<R> {
val studentIds = studentIds.orEmpty()
val studentIdsIndexes = createArguments(studentIds.size)
val studentIds = studentIds.orEmpty()
val studentIdsIndexes = createArguments(studentIds.size)
val kabinQuery =
"""SELECT * FROM BackPackEntity WHERE($studentIdsIndexes IS NULL OR studentId IN $studentIdsIndexes)"""
val kabinParametersCount = studentIds.size + studentIds.size + 0
val result = driver.executeQuery(
-1664847722,
kabinQuery,
mapper,
kabinParametersCount
)
{
studentIds.forEachIndexed { index, studentIdsChild ->
bindString(index, studentIdsChild)
}
studentIds.forEachIndexed { index, studentIdsChild ->
bindString(index + studentIds.orEmpty().size, studentIdsChild)
}
}
return result
}
from kabin.
Generated code for such case should and would look like this:
override fun <R> execute(mapper: SqlCursor.() -> QueryResult<R>): QueryResult<R> {
val studentIdsSize = studentIds.orEmpty().size
val studentIdsIndexes = createNullableArguments(studentIds?.size)
val kabinQuery =
"""SELECT * FROM BackPackEntity WHERE($studentIdsIndexes IS NULL OR studentId IN $studentIdsIndexes)"""
val kabinParametersCount = studentIdsSize + studentIdsSize + 0
val result = driver.executeQuery(
261282966,
kabinQuery,
mapper,
kabinParametersCount
)
{
studentIds?.forEachIndexed { index, studentIdsChild ->
bindString(index, studentIdsChild)
}
studentIds?.forEachIndexed { index, studentIdsChild ->
bindString(index + studentIdsSize, studentIdsChild)
}
}
return result
}
from kabin.
Fixed in 0.1.0-pre-alpha03
Further testing will be made in real environment
from kabin.
The generated queries, which look like this, have invalid SQL syntax:
NULL IS NULL OR type IN NULL
(?, ?) IS NULL OR type IN (?, ?)
- The
IN
operator can't be called withNULL
- (?, ?) can't be checked as
NULL
and will break parameters count and indexes
The generated queries should look like this:
NULL IS NULL OR type IN ()
:anyNotNullValue IS NULL OR type IN (?, ?)
from kabin.
Testing in a real environment resulted in a success, therefore, this issue is considered solved.
Changes were published to 0.1.0-pre-alpha04
from kabin.
Related Issues (13)
- Flow of a single element doesn't throw error when the element doesn't exist HOT 2
- Bug: db connection on android doesn't support ForeignKey HOT 3
- Primary keys are ignored, if the columns are inside an embedded class HOT 1
- Constraint foreign key exception when having conflicting operations inside one transaction HOT 5
- Bug: type mismatch for complex compounds having nullable and non-nullable types HOT 1
- Bug: Flow doesn't emit new value when compound have relation to list of entities HOT 2
- iOS: Creating scheme throws SQLiteExceptionErrorCode: transaction within a transaction HOT 2
- ForeignKey: Inconsistent behavior across different KMP targets, especially during migration
- Mapper: issue with the order of mapper constructor arguments in the generated database class
- Insert: Incorrect parameters count HOT 1
- Generator: method call conflicts
- Generator: java.io.FileNotFoundException (File name too long)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kabin.