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

First steps to move to SQLDelight #47

wants to merge 110 commits into from

Commits on Nov 22, 2024

  1. Set up SQLDelight

    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    2c3d7cc View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    2df8dba View commit details
    Browse the repository at this point in the history
  3. Remove nullability from downloadFile response

    It returns the result of apiCall, which is non-null.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    189238d View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    e78758f View commit details
    Browse the repository at this point in the history
  5. Convert Item sync adapter

    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    4fe3894 View commit details
    Browse the repository at this point in the history
  6. Convert Cashier sync adapter

    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    1566802 View commit details
    Browse the repository at this point in the history
  7. Create extensions with JSON utilities

    Since we no longer inherit from classes like AbstractReceipt, the JSON
    utils must be added separately.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    77cce26 View commit details
    Browse the repository at this point in the history
  8. Simplify ReceiptLine.toJSON()

    Removes the positionid of the add-on parent from the JSON and replaces
    it with just the addon_to ID.
    With SQLDelight, we can no longer directly resolve the relation with
    just the addon_to field, which means that we have to pass in either the
    ReceiptLine that addon_to points to or its positionid.
    Since the toJSON() is mostly used for logging purposes and the
    positionid is not strictly required, we can simplify the function here
    and add the equivalent of addon_to.positionid to the JSON afterwards in
    the caller where required.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    f17afd7 View commit details
    Browse the repository at this point in the history
  9. Create Item extensions

    Provide the same functionality as the getters on AbstractItem, but for
    the SQLDelight query result.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    b3f2a7d View commit details
    Browse the repository at this point in the history
  10. Add additional tables

    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    bcb2d4f View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    cf3bc0b View commit details
    Browse the repository at this point in the history
  12. Enable SQLDelight database on Android

    Android uses a different date format and requires the database version
    to be set correctly.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    85961f1 View commit details
    Browse the repository at this point in the history
  13. Add additional generic queries

    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    167da15 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    c0eec9e View commit details
    Browse the repository at this point in the history
  15. Update to latest schema

    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    7c9abca View commit details
    Browse the repository at this point in the history
  16. Change to BigDecimal.valueOf() in BigDecimalAdapter

    Uses the string representation of the double to create a BigDecimal. The
    previously used constructor on the other hand used the exact
    representation, which - to quote the docs - "can be somewhat
    unpredictable".
    This behaviour is also closer to requery's handling of decimal values.
    
    See https://docs.oracle.com/javase/7/docs/api/java/math/BigDecimal.html#BigDecimal(double)
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    1641d25 View commit details
    Browse the repository at this point in the history
  17. Add ItemAddOn.toJSON() method

    Useful for downstream testing.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    a5bda6c View commit details
    Browse the repository at this point in the history
  18. Update Closing column type mapping

    Aligns the data types with those used for other tables.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    57b3617 View commit details
    Browse the repository at this point in the history
  19. Add additional tables

    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    5f30d47 View commit details
    Browse the repository at this point in the history
  20. Update tests

    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    edd98df View commit details
    Browse the repository at this point in the history
  21. Add consistent handling of dates stored as text

    Some dates are stored as TEXT values in the database. Since they might
    contain unexpected values (such as "null"), it is more robust to handle
    them all through a single mapper class that performs consistent
    conversion.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    7665988 View commit details
    Browse the repository at this point in the history
  22. Convert Order sync adapter

    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    3903167 View commit details
    Browse the repository at this point in the history
  23. Fix Postgres/SQLite incompatibilities

    Maps all 4 byte Postgres ID columns to Long in order to be consistent
    with the remaining code. See PostgresIdAdapter.
    
    Moves getLastInsertedId queries to separate compat .sq file to fix
    conflicting query classes being generated.
    The .sq files under sqlite/ and postgres/ are only allowed to contain
    the CREATE TABLE statements. Otherwise they generate another query class
    that conflicts with the ones defined in common/. The solution is to
    create a .sq file with a different name so that it generates a query
    class with a different name (such as compat.sq for CompatQueries).
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    5bdff02 View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    c47c06a View commit details
    Browse the repository at this point in the history
  25. Define foreign keys as column constraints instead of table constraints

    SQLDelight has a machanism to sort create statements for a schema based
    on their dependencies. To achieve this, it creates a graph and sorts
    it topologically. During this process it only considers column level
    constraints. If a foreign key is defined as a table level constraint,
    the dependency is not considered.
    
    We were using table level constraints until now which resulted in create
    statements that were sorted alphabetically after file names.
    Since the .sq file names match their table names, calls to
    Schema.create() would fail on BadgeLayoutItem, which requires the table
    Item to exist.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    b350d6d View commit details
    Browse the repository at this point in the history
  26. Add missing foreign keys

    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    64539aa View commit details
    Browse the repository at this point in the history
  27. Move BaseDatabaseTest out of testFixtures

    This class now creates build problems when used in a Postgres project.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    a3f56d1 View commit details
    Browse the repository at this point in the history
  28. Add remaining table definitions

    Now that the schema might be created by SQLDelight, all tables must be
    defined.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    0a7bb86 View commit details
    Browse the repository at this point in the history
  29. Configuration menu
    Copy the full SHA
    3fa0c91 View commit details
    Browse the repository at this point in the history
  30. Update to latest schema

    See #46
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    c8b94b9 View commit details
    Browse the repository at this point in the history
  31. Add remaining CachedPdfImage queries

    robbi5 authored and antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    6fa69d8 View commit details
    Browse the repository at this point in the history
  32. Convert BadgeLayout and TicketLayout

    robbi5 authored and antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    b13a3f8 View commit details
    Browse the repository at this point in the history
  33. Configuration menu
    Copy the full SHA
    305633f View commit details
    Browse the repository at this point in the history
  34. Tweak query parameter naming

    Use explicit parameter names to better distinguish between columns that
    reference a local ID and those that reference server IDs.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    eea9665 View commit details
    Browse the repository at this point in the history
  35. Remove unused quota query

    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    3423d94 View commit details
    Browse the repository at this point in the history
  36. Run tests with Java 17

    The SQLDelight Gradle plugin is causing trouble with other JREs and
    there is no more reason to run Gradle with older Java versions on this
    project.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    8f5bcc2 View commit details
    Browse the repository at this point in the history
  37. Move protobuf plugin version to settings.gradle

    Fixes multi-module builds that have a top-level definition of the
    protobuf plugin.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    4c65a51 View commit details
    Browse the repository at this point in the history
  38. Configuration menu
    Copy the full SHA
    1b3ce76 View commit details
    Browse the repository at this point in the history
  39. Configuration menu
    Copy the full SHA
    77f79e2 View commit details
    Browse the repository at this point in the history
  40. Configuration menu
    Copy the full SHA
    5e24e29 View commit details
    Browse the repository at this point in the history
  41. Migrate EventSyncAdapter

    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    3c2ce78 View commit details
    Browse the repository at this point in the history
  42. Migrate SubEventSyncAdapter

    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    0c21064 View commit details
    Browse the repository at this point in the history
  43. Use ID instead of server ID for updateFromJson queries

    While server IDs should work just fine, it is still safer to use the
    tables' primary keys to refrence existing records.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    b213bc8 View commit details
    Browse the repository at this point in the history
  44. Add back event slug filter to migrated runBatch queries

    Some of the migrated sync adapters are missing the event slug filter in
    runBatch that was present in the original version.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    7997270 View commit details
    Browse the repository at this point in the history
  45. Migrate TaxRuleSyncAdapter

    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    095f070 View commit details
    Browse the repository at this point in the history
  46. Re-arrange SqBaseConditionalSyncAdapter method order

    Improves readability and creates a better basesline for the next
    migrations.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    ccfe923 View commit details
    Browse the repository at this point in the history
  47. Migrate QuestionSyncAdapter

    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    de3444c View commit details
    Browse the repository at this point in the history
  48. Migrate CheckInListSyncAdapter

    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    9c8ff68 View commit details
    Browse the repository at this point in the history
  49. Migrate AllEventsSyncAdapter

    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    abd810a View commit details
    Browse the repository at this point in the history
  50. Configuration menu
    Copy the full SHA
    3250792 View commit details
    Browse the repository at this point in the history
  51. Migrate BadgeLayoutSyncAdapter

    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    31981bf View commit details
    Browse the repository at this point in the history
  52. Configuration menu
    Copy the full SHA
    7569a6b View commit details
    Browse the repository at this point in the history
  53. Configuration menu
    Copy the full SHA
    a01c0ce View commit details
    Browse the repository at this point in the history
  54. Use consistent column naming on CheckInList

    SQLDelight does not like case differences between SQLite and Postgres.
    Since Postgres converts them to lowercase anyway, it's safe to use the
    SQLite naming.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    0e0bd3c View commit details
    Browse the repository at this point in the history
  55. Configuration menu
    Copy the full SHA
    dd8d194 View commit details
    Browse the repository at this point in the history
  56. Add not-null assertion to columns with inconsistent nullability

    The columns on CheckInList_Item and Question_Item have inconsistent
    definitions between Postgres and SQLite. On Postgres the are created as
    NOT NULL, which results in SQLDelight generating slightly different data
    classes between the two.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    a5ef373 View commit details
    Browse the repository at this point in the history
  57. Configuration menu
    Copy the full SHA
    1d1922c View commit details
    Browse the repository at this point in the history
  58. Configuration menu
    Copy the full SHA
    6848bcc View commit details
    Browse the repository at this point in the history
  59. Configuration menu
    Copy the full SHA
    a2e8a20 View commit details
    Browse the repository at this point in the history
  60. Migrate QuotaSyncAdapter

    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    173f423 View commit details
    Browse the repository at this point in the history
  61. Clean up old base classes

    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    d900511 View commit details
    Browse the repository at this point in the history
  62. Configuration menu
    Copy the full SHA
    aec2480 View commit details
    Browse the repository at this point in the history
  63. Convert Quota.available to Boolean on Postgres

    Makes the type of this column consistent with SQLite
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    ce6e96d View commit details
    Browse the repository at this point in the history
  64. Use IllegalArgumentException for PostgresIdAdapter

    It's a better fit than IllegalStateException.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    b08027e View commit details
    Browse the repository at this point in the history
  65. Fix build warnings

    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    f544bf5 View commit details
    Browse the repository at this point in the history
  66. Tidy up queryKnownIDs

    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    472a3f7 View commit details
    Browse the repository at this point in the history
  67. Validate scale in BigDecimalAdapter

    Since we apply a scale of 2 when converting column values, we should
    avoid storing any higher precisions numbers.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    e2fc471 View commit details
    Browse the repository at this point in the history
  68. Move toScaledBigDecimal/toScaledBigDecimalOrZero to BigDecimalAdapter

    Any changes to the adapter might also affect the conversions, so it
    makes sense to keep them in the same file.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    d1b297e View commit details
    Browse the repository at this point in the history
  69. Move models to libpretixsync

    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    bbeba89 View commit details
    Browse the repository at this point in the history
  70. Configuration menu
    Copy the full SHA
    2eb593e View commit details
    Browse the repository at this point in the history
  71. Configuration menu
    Copy the full SHA
    9a68913 View commit details
    Browse the repository at this point in the history
  72. Remove autoPersist()

    With removed batching and the new insert()/update() methods,
    autoPersist() is no longer needed.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    d5cad8b View commit details
    Browse the repository at this point in the history
  73. Remove database version from Gradle files

    SQLDelight already uses the migration files to determine the DB version.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    20dba52 View commit details
    Browse the repository at this point in the history
  74. Migrate Question usage

    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    0a4463b View commit details
    Browse the repository at this point in the history
  75. Configuration menu
    Copy the full SHA
    e0327cc View commit details
    Browse the repository at this point in the history
  76. Configuration menu
    Copy the full SHA
    91e8e05 View commit details
    Browse the repository at this point in the history
  77. Configuration menu
    Copy the full SHA
    09fa413 View commit details
    Browse the repository at this point in the history
  78. Remove unused deleted counter

    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    eb5c65b View commit details
    Browse the repository at this point in the history
  79. Create CheckIn model

    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    9d26ac2 View commit details
    Browse the repository at this point in the history
  80. Configuration menu
    Copy the full SHA
    21c330a View commit details
    Browse the repository at this point in the history
  81. Configuration menu
    Copy the full SHA
    450ce71 View commit details
    Browse the repository at this point in the history
  82. Fix question dependencies

    Question models were missing the getDependencyValues() override.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    f3b9cca View commit details
    Browse the repository at this point in the history
  83. Fix java.time to Joda conversion

    We were providing the wrong type of Instant.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    975715e View commit details
    Browse the repository at this point in the history
  84. Configuration menu
    Copy the full SHA
    7ad4ee6 View commit details
    Browse the repository at this point in the history
  85. Configuration menu
    Copy the full SHA
    0148e06 View commit details
    Browse the repository at this point in the history
  86. Configuration menu
    Copy the full SHA
    34104f5 View commit details
    Browse the repository at this point in the history
  87. Configuration menu
    Copy the full SHA
    2d88158 View commit details
    Browse the repository at this point in the history
  88. Migrate majority of OrderPosition in AsyncCheckProvider

    Some query building code remains which should be migrated in a separate
    step.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    66d5e78 View commit details
    Browse the repository at this point in the history
  89. Configuration menu
    Copy the full SHA
    f97bb6a View commit details
    Browse the repository at this point in the history
  90. Configuration menu
    Copy the full SHA
    a514446 View commit details
    Browse the repository at this point in the history
  91. Configuration menu
    Copy the full SHA
    e038275 View commit details
    Browse the repository at this point in the history
  92. Fix typing issue between SQLite and Postgres

    SQLDelight returns the Long value directly on Postgres while it wraps it
    in a result type on SQLDelight.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    3e2287f View commit details
    Browse the repository at this point in the history
  93. Configuration menu
    Copy the full SHA
    01c3fae View commit details
    Browse the repository at this point in the history
  94. Configuration menu
    Copy the full SHA
    7abbd2d View commit details
    Browse the repository at this point in the history
  95. Add missing listed_price to item variation

    robbi5 authored and antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    4937a4a View commit details
    Browse the repository at this point in the history
  96. Migrate OrderCleanup

    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    2e399fd View commit details
    Browse the repository at this point in the history
  97. Configuration menu
    Copy the full SHA
    bb1cf20 View commit details
    Browse the repository at this point in the history
  98. Configuration menu
    Copy the full SHA
    41150ea View commit details
    Browse the repository at this point in the history
  99. Configuration menu
    Copy the full SHA
    51ea1e8 View commit details
    Browse the repository at this point in the history
  100. Configuration menu
    Copy the full SHA
    6fb7d8d View commit details
    Browse the repository at this point in the history
  101. Configuration menu
    Copy the full SHA
    a7c0e29 View commit details
    Browse the repository at this point in the history
  102. Configuration menu
    Copy the full SHA
    b95c50e View commit details
    Browse the repository at this point in the history
  103. Configuration menu
    Copy the full SHA
    52f3b3b View commit details
    Browse the repository at this point in the history
  104. Use 0/1 for booleans in the queries, the shipped sqlite version on an…

    …droid is too old for TRUE/FALSE (PRETIXPOS-1HH)
    robbi5 authored and antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    9d1d180 View commit details
    Browse the repository at this point in the history
  105. Remove shared SimpleDateFormat instances in date adapters

    Since SimpleDateFormat is not thread safe, we might be running into race
    conditions here actually.
    Re-creating a new instance is expensive, so this is only a temporary
    fix while we validate a change to DateTimeFormatter.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    357a01d View commit details
    Browse the repository at this point in the history
  106. Use DateTimeFormatter in date adapters

    Should guarantee thread safety without constantly re-creating formatters.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    5a444bc View commit details
    Browse the repository at this point in the history
  107. Add issue_giftcard to test Items

    Reduces warnings when we convert them to models.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    7701aaf View commit details
    Browse the repository at this point in the history
  108. Fix boolean handling under Postgres

    The change in cce5bf9 fixed booleans on older SQLite versions, but broke
    the queries for Postgres. This is a workaround that should make both
    databases happy.
    Since Postgres is extra pedantic in CASE epxressions, the complex order
    position queries had to be moved to the set of dialect-specific queries.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    3a08d8b View commit details
    Browse the repository at this point in the history
  109. Configuration menu
    Copy the full SHA
    434c9f1 View commit details
    Browse the repository at this point in the history
  110. Move query to lock QueuedOrder to compat queries

    Updates with 1 instead of TRUE also don't work on Postgres.
    antweb committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    eb80c46 View commit details
    Browse the repository at this point in the history