-
Notifications
You must be signed in to change notification settings - Fork 17
99-KMP.Database. #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
99-KMP.Database. #110
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works like a charm 👍See comments for some questions / remarks.
app/build.gradle
Outdated
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2" | ||
|
||
implementation "com.squareup.okhttp3:logging-interceptor:4.2.1" | ||
implementation "com.squareup.sqldelight:android-driver:1.2.1" |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
@@ -0,0 +1,80 @@ | |||
{ |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
private lateinit var pageTitle: String | ||
private lateinit var link: String | ||
|
||
private val problem: Problem |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
} | ||
} | ||
DatabaseClient.userDao.update(user) | ||
withContext(Dispatchers.IO) { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
||
jvmMain { | ||
dependencies { | ||
api "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
) { | ||
fun identify() = "$contestId$index" | ||
|
||
fun copy(id: Long = this.id, name: String = this.name, enName: String = this.enName, ruName: String = this.ruName, index: String = this.index, contestId: Long = this.contestId, contestName: String = this.contestName, contestTime: Long = this.contestTime, isFavourite: Boolean = this.isFavourite) = |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
class Problem( |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
||
lateinit var sqlDriver: SqlDriver | ||
|
||
/*val store = Store( |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
@@ -0,0 +1 @@ | |||
CREATE TABLE Contest (id INTEGER NOT NULL, name TEXT NOT NULL, time INTEGER NOT NULL, phase TEXT NOT NULL, PRIMARY KEY(id)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If migrations doesn't work in the current version, it's better to remove them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to say if migrations
. But yes, I'm almost sure these migrations aren't needed. Can you check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They work, otherwise, how I install application to old version db and everything work?
SELECT * FROM User; | ||
|
||
insert: | ||
INSERT OR REPLACE INTO User(avatar, rank, handle, rating, maxRating, firstName, lastName, ratingChanges) VALUES(?,?,?,?,?,?,?,?); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've see that you have if
for 2 inserts, but they both are INSERT OR REPLACE
, so not sure you can't get rid of one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first one really insert User, second one - update. They are different, because second one have 'id' parametre, unlike first one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job 👍
No description provided.