jackson icon indicating copy to clipboard operation
jackson copied to clipboard

Feat: sqlite and turso support

Open nadilas opened this issue 1 year ago • 1 comments
trafficstars

What does this PR do?

Fixes # (issue)

Type of change

  • [ ] Updated dependencies
  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [x] This change requires a documentation update

How should this be tested?

  • [x] Existing unit tests

Checklist:

  • [ ] My code follows the style guidelines of this project
  • [ ] I have performed a self-review of my own code and corrected any misspellings
  • [ ] I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] My changes generate no new warnings
  • [ ] I have added tests that prove my fix is effective or that my feature works
  • [ ] New and existing unit tests pass locally with my changes

nadilas avatar May 21 '24 10:05 nadilas

Two interesting issues emerge:

  • [x] TypeORM sqlite doesn't seem to respect the order by clause
  • [x] The const wanted setup in tests does not seem to reflect the input params
# ✖ getAll(): sql: sqlite > without pagination params should return all the records upto options.pageLimit in DESC order by creation time test/db/db.test.ts:297:9

query: SELECT "JacksonStore"."value" AS "JacksonStore_value", "JacksonStore"."iv" AS "JacksonStore_iv", "JacksonStore"."tag" AS "JacksonStore_tag", "JacksonStore"."key"
 AS "JacksonStore_key" FROM "jackson_store" "JacksonStore" WHERE (("JacksonStore"."namespace" = ?)) ORDER BY "JacksonStore"."createdAt" DESC -- PARAMETERS:
["saml:config:17163730417542922a3ed"]
{
  "(await connectionStore.getAll()).data": [
    { id: '1', name: 'Deepak', city: 'London' },
    { id: '2', name: 'Sama', city: 'London' },
    { id: '3', name: 'Samuel Jackson', city: 'Delhi' }
  ],
  wanted: [
    { id: '3', name: 'Samuel Jackson', city: 'Delhi' },
    { id: '2', name: 'Sama', city: 'London' }
  ]
}


# ✖ getAll(): sql: sqlite > with pagination params should return all the records upto options.pageLimit in DESC order by creation time test/db/db.test.ts:301:9

query: SELECT "JacksonStore"."value" AS "JacksonStore_value", "JacksonStore"."iv" AS "JacksonStore_iv", "JacksonStore"."tag" AS "JacksonStore_tag", "JacksonStore"."key"
 AS "JacksonStore_key" FROM "jackson_store" "JacksonStore" WHERE (("JacksonStore"."namespace" = ?)) ORDER BY "JacksonStore"."createdAt" DESC LIMIT 2 -- PARAMETERS:
["saml:config:17163730417542922a3ed"]
{
  "(await connectionStore.getAll(0, 2)).data": [
    { id: '1', name: 'Deepak', city: 'London' },
    { id: '2', name: 'Sama', city: 'London' }
  ],
  wanted: [
    { id: '3', name: 'Samuel Jackson', city: 'Delhi' },
    { id: '2', name: 'Sama', city: 'London' }
  ]
}

# ✖ getAll(): sql: sqlite > with pageLimit set to 0 should return all the records upto options.pageLimit in DESC order by creation time test/db/db.test.ts:305:9

query: SELECT "JacksonStore"."value" AS "JacksonStore_value", "JacksonStore"."iv" AS "JacksonStore_iv", "JacksonStore"."tag" AS "JacksonStore_tag", "JacksonStore"."key"
 AS "JacksonStore_key" FROM "jackson_store" "JacksonStore" WHERE (("JacksonStore"."namespace" = ?)) ORDER BY "JacksonStore"."createdAt" DESC -- PARAMETERS:
["saml:config:17163730417542922a3ed"]
{
  "(await connectionStore.getAll(0, 0)).data": [
    { id: '1', name: 'Deepak', city: 'London' },
    { id: '2', name: 'Sama', city: 'London' },
    { id: '3', name: 'Samuel Jackson', city: 'Delhi' }
  ],
  wanted: [
    { id: '3', name: 'Samuel Jackson', city: 'Delhi' },
    { id: '2', name: 'Sama', city: 'London' }
  ]
}

# ✖ getAll(): sql: sqlite > with pageLimit > options.pageLimit should return all the records upto options.pageLimit in DESC order by creation time test/db/db.test.ts:309:9

query: SELECT "JacksonStore"."value" AS "JacksonStore_value", "JacksonStore"."iv" AS "JacksonStore_iv", "JacksonStore"."tag" AS "JacksonStore_tag", "JacksonStore"."key"
 AS "JacksonStore_key" FROM "jackson_store" "JacksonStore" WHERE (("JacksonStore"."namespace" = ?)) ORDER BY "JacksonStore"."createdAt" DESC LIMIT 3 -- PARAMETERS:
["saml:config:17163730417542922a3ed"]
{
  "(await connectionStore.getAll(0, 3)).data": [
    { id: '1', name: 'Deepak', city: 'London' },
    { id: '2', name: 'Sama', city: 'London' },
    { id: '3', name: 'Samuel Jackson', city: 'Delhi' }
  ],
  wanted: [
    { id: '3', name: 'Samuel Jackson', city: 'Delhi' },
    { id: '2', name: 'Sama', city: 'London' }
  ]
}

# ✖ getAll(): sql: sqlite > records are sorted in DESC order test/db/db.test.ts:338:11

query: SELECT "JacksonStore"."value" AS "JacksonStore_value", "JacksonStore"."iv" AS "JacksonStore_iv", "JacksonStore"."tag" AS "JacksonStore_tag", "JacksonStore"."key"
 AS "JacksonStore_key" FROM "jackson_store" "JacksonStore" WHERE (("JacksonStore"."namespace" = ?)) ORDER BY "JacksonStore"."createdAt" DESC LIMIT 2 -- PARAMETERS:
["saml:config:17163730417542922a3ed"]
{
  "await connectionStore.getAll(0, 2, undefined, 'DESC')": [
    { id: '1', name: 'Deepak', city: 'London' },
    { id: '2', name: 'Sama', city: 'London' },
  ],
  wanted: [
    { id: '3', name: 'Samuel Jackson', city: 'Delhi' },
    { id: '2', name: 'Sama', city: 'London' }
  ]
}

nadilas avatar May 22 '24 10:05 nadilas