Skip to content
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

First steps to move to SQLDelight #47

Open
wants to merge 110 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
2c3d7cc
Set up SQLDelight
antweb May 3, 2024
2df8dba
Set up SQLDelight database and initial queries
antweb May 3, 2024
189238d
Remove nullability from downloadFile response
antweb May 3, 2024
e78758f
Create base classes for SQLDelight sync adapters
antweb May 3, 2024
4fe3894
Convert Item sync adapter
antweb May 3, 2024
1566802
Convert Cashier sync adapter
antweb May 3, 2024
77cce26
Create extensions with JSON utilities
antweb May 3, 2024
f17afd7
Simplify ReceiptLine.toJSON()
antweb May 6, 2024
b3f2a7d
Create Item extensions
antweb May 7, 2024
bcb2d4f
Add additional tables
antweb May 8, 2024
cf3bc0b
Move Settings.fiscalJSON extension to core-pos-sdk
antweb May 16, 2024
85961f1
Enable SQLDelight database on Android
antweb May 16, 2024
167da15
Add additional generic queries
antweb May 17, 2024
c0eec9e
Create date adapter for Postgres
antweb May 17, 2024
7c9abca
Update to latest schema
antweb May 29, 2024
1641d25
Change to BigDecimal.valueOf() in BigDecimalAdapter
antweb Jun 10, 2024
a5bda6c
Add ItemAddOn.toJSON() method
antweb Jun 10, 2024
57b3617
Update Closing column type mapping
antweb Jun 10, 2024
5f30d47
Add additional tables
antweb Jun 10, 2024
edd98df
Update tests
antweb Jun 10, 2024
7665988
Add consistent handling of dates stored as text
antweb Jun 13, 2024
3903167
Convert Order sync adapter
antweb Jun 17, 2024
5bdff02
Fix Postgres/SQLite incompatibilities
antweb Jun 20, 2024
c47c06a
Set database version for Postgres builds
antweb Jun 22, 2024
b350d6d
Define foreign keys as column constraints instead of table constraints
antweb Jun 22, 2024
64539aa
Add missing foreign keys
antweb Jun 22, 2024
a3f56d1
Move BaseDatabaseTest out of testFixtures
antweb Jun 24, 2024
0a7bb86
Add remaining table definitions
antweb Jun 25, 2024
3fa0c91
Add query to truncate all tables
antweb Jun 26, 2024
c8b94b9
Update to latest schema
antweb Jun 27, 2024
6fa69d8
Add remaining CachedPdfImage queries
robbi5 Jul 15, 2024
b13a3f8
Convert BadgeLayout and TicketLayout
robbi5 Jul 15, 2024
305633f
Add OrderPosition.selectByServerId query
antweb Jul 23, 2024
eea9665
Tweak query parameter naming
antweb Jul 23, 2024
3423d94
Remove unused quota query
antweb Jul 23, 2024
8f5bcc2
Run tests with Java 17
antweb Jul 23, 2024
4c65a51
Move protobuf plugin version to settings.gradle
antweb Jul 24, 2024
1b3ce76
Fix CachedPdfImage query under Postgres
antweb Jul 24, 2024
77f79e2
Migrate ItemCategorySyncAdapter
antweb Jul 24, 2024
5e24e29
Migrate SettingsSyncAdapter / InvoiceSettingsSyncAdapter
antweb Jul 24, 2024
3c2ce78
Migrate EventSyncAdapter
antweb Jul 25, 2024
0c21064
Migrate SubEventSyncAdapter
antweb Jul 25, 2024
b213bc8
Use ID instead of server ID for updateFromJson queries
antweb Jul 25, 2024
7997270
Add back event slug filter to migrated runBatch queries
antweb Jul 25, 2024
095f070
Migrate TaxRuleSyncAdapter
antweb Jul 25, 2024
ccfe923
Re-arrange SqBaseConditionalSyncAdapter method order
antweb Jul 25, 2024
de3444c
Migrate QuestionSyncAdapter
antweb Jul 25, 2024
9c8ff68
Migrate CheckInListSyncAdapter
antweb Jul 25, 2024
abd810a
Migrate AllEventsSyncAdapter
antweb Jul 25, 2024
3250792
Migrate AllSubEventsSyncAdapter
antweb Jul 26, 2024
31981bf
Migrate BadgeLayoutSyncAdapter
antweb Jul 26, 2024
7569a6b
Migrate BadgeLayoutItemSyncAdapter
antweb Jul 26, 2024
a01c0ce
Migrate MediumKeySetSyncAdapter
antweb Jul 26, 2024
0e0bd3c
Use consistent column naming on CheckInList
antweb Jul 26, 2024
dd8d194
Migrate BlockedTicketSecretSyncAdapter
antweb Jul 26, 2024
a5ef373
Add not-null assertion to columns with inconsistent nullability
antweb Jul 26, 2024
1d1922c
Migrate RevokedTicketSecretSyncAdapter
antweb Jul 26, 2024
6848bcc
Migrate ReusableMediaSyncAdapter
antweb Jul 26, 2024
a2e8a20
Migrate TicketLayoutSyncAdapter
antweb Jul 27, 2024
173f423
Migrate QuotaSyncAdapter
antweb Jul 27, 2024
d900511
Clean up old base classes
antweb Jul 27, 2024
aec2480
Finalize sync adapter migration
antweb Jul 27, 2024
ce6e96d
Convert Quota.available to Boolean on Postgres
antweb Jul 31, 2024
b08027e
Use IllegalArgumentException for PostgresIdAdapter
antweb Jul 31, 2024
f544bf5
Fix build warnings
antweb Jul 31, 2024
472a3f7
Tidy up queryKnownIDs
antweb Jul 31, 2024
e2fc471
Validate scale in BigDecimalAdapter
antweb Aug 9, 2024
d1b297e
Move toScaledBigDecimal/toScaledBigDecimalOrZero to BigDecimalAdapter
antweb Aug 9, 2024
bbeba89
Move models to libpretixsync
antweb Aug 9, 2024
2eb593e
Add receipt ID to ReceiptLine modelAdd receipt ID to ReceiptLine model
antweb Aug 30, 2024
9a68913
Enable autoPersist for BlockedTicketSecretSyncAdapter
antweb Sep 20, 2024
d5cad8b
Remove autoPersist()
antweb Sep 20, 2024
20dba52
Remove database version from Gradle files
antweb Sep 20, 2024
0a4463b
Migrate Question usage
antweb Sep 7, 2024
e0327cc
Migrate remaining usage of BlockedTicketSecret and RevokedTicketSecret
antweb Sep 7, 2024
91e8e05
Migrate remaining usage of SubEvent
antweb Sep 20, 2024
09fa413
Migrate remaining usage of Event
antweb Sep 20, 2024
eb5c65b
Remove unused deleted counter
antweb Sep 20, 2024
9d26ac2
Create CheckIn model
antweb Sep 20, 2024
21c330a
Migrate remaining usage of CheckIn
antweb Sep 20, 2024
450ce71
Fix event slug in AllSubEventsSyncAdapter
antweb Sep 27, 2024
f3b9cca
Fix question dependencies
antweb Sep 27, 2024
975715e
Fix java.time to Joda conversion
antweb Sep 27, 2024
7ad4ee6
Migrate remaining usage of CheckInList
antweb Sep 27, 2024
0148e06
Migrate remaining usage of Item and ItemCategory
antweb Sep 27, 2024
34104f5
Expand wildcard imports in AsyncCheckProviderTest
antweb Sep 27, 2024
2d88158
Migrate remaining usage of ReusableMedium
antweb Oct 3, 2024
66d5e78
Migrate majority of OrderPosition in AsyncCheckProvider
antweb Oct 3, 2024
f97bb6a
Migrate search query in AsyncCheckProvider
antweb Oct 4, 2024
a514446
Expand wildcard import in OrderSyncTest
antweb Oct 4, 2024
e038275
Migrate remaining usage of ResourceSyncStatus
antweb Oct 4, 2024
3e2287f
Fix typing issue between SQLite and Postgres
antweb Oct 4, 2024
01c3fae
Fix now datetime override in tests
antweb Oct 18, 2024
7abbd2d
Migrate AsyncCheckProvider.status()
antweb Oct 18, 2024
4937a4a
Add missing listed_price to item variation
robbi5 Oct 23, 2024
2e399fd
Migrate OrderCleanup
antweb Oct 26, 2024
bb1cf20
Migrate remaining usage of Order / OrderPosition
antweb Oct 26, 2024
41150ea
Migrate remaining usage of QueuedCall
antweb Oct 26, 2024
51ea1e8
Migrate remaining usage of QueuedCheckIn
antweb Oct 27, 2024
6fb7d8d
Remove dataStore arg from check providers
antweb Oct 27, 2024
a7c0e29
Add query to select BadgeLayoutItem by event slug
antweb Oct 27, 2024
b95c50e
Migrate remaining usage of Closing
antweb Oct 27, 2024
52f3b3b
Migrate remaining usage of QueuedOrder
antweb Oct 27, 2024
9d1d180
Use 0/1 for booleans in the queries, the shipped sqlite version on an…
robbi5 Nov 13, 2024
357a01d
Remove shared SimpleDateFormat instances in date adapters
antweb Nov 15, 2024
5a444bc
Use DateTimeFormatter in date adapters
antweb Nov 15, 2024
7701aaf
Add issue_giftcard to test Items
antweb Nov 22, 2024
3a08d8b
Fix boolean handling under Postgres
antweb Nov 22, 2024
434c9f1
Remove id parameter from QueuedOrder INSERT
antweb Nov 22, 2024
eb80c46
Move query to lock QueuedOrder to compat queries
antweb Nov 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ on:

jobs:
test:
strategy:
matrix:
java: [ '11' ]

name: test with java ${{ matrix.java }}

name: test
runs-on: ubuntu-latest

steps:
Expand All @@ -22,7 +17,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
java-version: '17'
distribution: 'temurin'

- name: Run Gradle
Expand Down
15 changes: 14 additions & 1 deletion libpretixsync/build-postgres.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ plugins {
id 'jacoco'
id 'org.jetbrains.kotlin.jvm'
id 'org.jetbrains.kotlin.kapt'
id 'com.google.protobuf' version '0.9.4'
id 'com.google.protobuf'
id 'com.github.gmazzo.buildconfig' version "5.3.5"
id 'org.gradle.idea'
id 'app.cash.sqldelight'
}
apply from: 'versions.gradle'

Expand Down Expand Up @@ -107,6 +108,8 @@ dependencies {
implementation "net.i2p.crypto:eddsa:$eddsa_version"
implementation "com.google.protobuf:protobuf-javalite:$protobuf_version"

implementation "app.cash.sqldelight:jdbc-driver:$sqldelight_version"

kapt "io.requery:requery-processor:$requery_version"
annotationProcessor "javax.annotation:jsr250-api:$jsr250_version"

Expand All @@ -121,3 +124,13 @@ task copyTestResources(type: Copy) {
into "${buildDir}/classes/test"
}
processTestResources.dependsOn copyTestResources

sqldelight {
databases {
SyncDatabase {
packageName = "eu.pretix.libpretixsync.sqldelight"
dialect "app.cash.sqldelight:postgresql-dialect:$sqldelight_version"
srcDirs('src/main/sqldelight/postgres', 'src/main/sqldelight/common', 'src/main/sqldelight/migrations')
}
}
}
19 changes: 18 additions & 1 deletion libpretixsync/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ plugins {
id 'jacoco'
id 'org.jetbrains.kotlin.jvm'
id 'org.jetbrains.kotlin.kapt'
id 'com.google.protobuf' version '0.9.4'
id 'com.google.protobuf'
id 'com.github.gmazzo.buildconfig' version '5.3.5'
id 'org.gradle.idea'
id 'app.cash.sqldelight'
}
apply from: 'versions.gradle'

Expand Down Expand Up @@ -104,6 +105,8 @@ dependencies {
implementation "net.i2p.crypto:eddsa:$eddsa_version"
implementation "com.google.protobuf:protobuf-javalite:$protobuf_version"

implementation "app.cash.sqldelight:sqlite-driver:$sqldelight_version"

kapt "io.requery:requery-processor:$requery_version"
annotationProcessor "javax.annotation:jsr250-api:$jsr250_version"

Expand All @@ -118,3 +121,17 @@ task copyTestResources(type: Copy) {
into "${buildDir}/classes/test"
}
processTestResources.dependsOn copyTestResources

sqldelight {
databases {
SyncDatabase {
packageName = "eu.pretix.libpretixsync.sqldelight"
srcDirs('src/main/sqldelight/sqlite', 'src/main/sqldelight/common', 'src/main/sqldelight/migrations')

// Oldest dialect supported by SQLDelight 2.0.2
// In Android projects, it will auto-select based on SDK
// but not go lower than 3.18 (Android 9 is still on 3.8)
dialect "app.cash.sqldelight:sqlite-3-18-dialect:$sqldelight_version"
}
}
}
3 changes: 2 additions & 1 deletion libpretixsync/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ pluginManagement {
// but building it inside the multi module project doesn't exit with "unknown version already on classpath" error
plugins {
id "org.jetbrains.kotlin.jvm" version "1.9.23" apply false
id "com.google.protobuf" version "0.9.4" apply false
id "app.cash.sqldelight" version "2.0.2" apply false
}

rootProject.name = 'eu.pretix.libpretixsync'

Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package eu.pretix.libpretixsync.api
import eu.pretix.libpretixsync.DummySentryImplementation
import eu.pretix.libpretixsync.SentryInterface
import eu.pretix.libpretixsync.config.ConfigStore
import eu.pretix.libpretixsync.db.AbstractQueuedCheckIn
import eu.pretix.libpretixsync.db.Answer
import eu.pretix.libpretixsync.db.Question
import eu.pretix.libpretixsync.db.QueuedCheckIn
import eu.pretix.libpretixsync.models.Question
import eu.pretix.libpretixsync.utils.NetUtils
import eu.pretix.libpretixsync.utils.URLFragmentEncoder
import okhttp3.MediaType
Expand Down Expand Up @@ -46,7 +46,7 @@ open class PretixApi(url: String, key: String, orgaSlug: String, version: Int, h
fun redeem(eventSlug: String, secret: String, datetime: Date?, force: Boolean, nonce: String?, answers: List<Answer>?, listId: Long, ignore_unpaid: Boolean, pdf_data: Boolean, type: String?, source_type: String?, callTimeout: Long? = null, questions_supported: Boolean = true): ApiResponse {
var dt: String? = null
if (datetime != null) {
dt = QueuedCheckIn.formatDatetime(datetime)
dt = AbstractQueuedCheckIn.formatDatetime(datetime)
}
return redeem(eventSlug, secret, dt, force, nonce, answers, listId, ignore_unpaid, pdf_data, type, source_type, callTimeout, questions_supported)
}
Expand All @@ -73,9 +73,9 @@ open class PretixApi(url: String, key: String, orgaSlug: String, version: Int, h
"pdf" -> "application/pdf".toMediaTypeOrNull()!!
else -> "application/unknown".toMediaTypeOrNull()!!
}, a.value.split("/").last())
answerbody.put("" + (a.question as Question).getServer_id(), fileid)
answerbody.put("" + (a.question as Question).serverId, fileid)
} else {
answerbody.put("" + (a.question as Question).getServer_id(), a.value)
answerbody.put("" + (a.question as Question).serverId, a.value)
}
}
}
Expand All @@ -93,7 +93,7 @@ open class PretixApi(url: String, key: String, orgaSlug: String, version: Int, h
fun redeem(lists: List<Long>, secret: String, datetime: Date?, force: Boolean, nonce: String?, answers: List<Answer>?, ignore_unpaid: Boolean, pdf_data: Boolean, type: String?, source_type: String?, callTimeout: Long? = null, questions_supported: Boolean = true): ApiResponse {
var dt: String? = null
if (datetime != null) {
dt = QueuedCheckIn.formatDatetime(datetime)
dt = AbstractQueuedCheckIn.formatDatetime(datetime)
}
return redeem(lists, secret, dt, force, nonce, answers, ignore_unpaid, pdf_data, type, source_type, callTimeout, questions_supported)
}
Expand All @@ -120,9 +120,9 @@ open class PretixApi(url: String, key: String, orgaSlug: String, version: Int, h
"pdf" -> "application/pdf".toMediaTypeOrNull()!!
else -> "application/unknown".toMediaTypeOrNull()!!
}, a.value.split("/").last())
answerbody.put("" + (a.question as Question).getServer_id(), fileid)
answerbody.put("" + (a.question as Question).serverId, fileid)
} else {
answerbody.put("" + (a.question as Question).getServer_id(), a.value)
answerbody.put("" + (a.question as Question).serverId, a.value)
}
}
}
Expand Down Expand Up @@ -314,7 +314,7 @@ open class PretixApi(url: String, key: String, orgaSlug: String, version: Int, h
}

@Throws(ApiException::class)
open fun downloadFile(full_url: String): ApiResponse? {
open fun downloadFile(full_url: String): ApiResponse {
var request = Request.Builder()
.url(full_url)
.header("Authorization", "Device $key")
Expand Down
Loading
Loading