-
Notifications
You must be signed in to change notification settings - Fork 545
Closed
Description
Build Environment
SQLDelight version: 1.4.0
OS: macOS 10.15.5
Gradle version: 6.6
Kotlin version: 1.3.72
AGP Version: 4.0.1
Example:
song.sq
CREATE TABLE song(
title TEXT,
track_number INTEGER,
album_id INTEGER
);
selectSongsByAlbumId:
SELECT * FROM song WHERE album_id = ?;
This compiles to the following:
SongQueries.kt
interface SongQueries : Transacter {
fun <T : Any> selectSongsByAlbumId(album_id: Long?, mapper: (
title: String?,
track_number: Long?,
album_id: Long?
) -> T): Query<T>
fun selectSongsByAlbumId(album_id: Long?): Query<Song>
}
Everything works correctly so far. Adding another .sq file with a view that selects all columns from the table changes things:
first_song_in_album.sq
CREATE VIEW first_song_in_album AS
SELECT * FROM song WHERE track_number = 1;
This causes the selectSongsByAlbumId
query to be compiled with the wrong return type:
SongQueries.kt
interface SongQueries : Transacter {
fun <T : Any> selectSongsByAlbumId(album_id: Long?, mapper: (
title: String?,
track_number: Long?,
album_id: Long?
) -> T): Query<T>
fun selectSongsByAlbumId(album_id: Long?): Query<First_song_in_album> // Instead of Query<Song>
}
The First_song_in_album
type does not exist and the build fails because of this:
SongQueries.kt: (16, 52): Unresolved reference: First_song_in_album
Additional information
- The IDE plugin generates the return type correctly as
Query<Song>
. Only when building with the Gradle plugin does this problem occur. - The problem only occurs when both the
selectSongsByAlbumId
query and thefirst_song_in_album
view select all columns (*) from the table. - The problem only occurs when the query and the view are in separate files.