Skip to content

Commit

Permalink
refactor: Upgrade PostgreSQL & PostGIS for development
Browse files Browse the repository at this point in the history
  • Loading branch information
sixmen committed Nov 13, 2024
1 parent 690a8c4 commit e1f17b7
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
ports:
- 21861:27017
postgres:
image: mdillon/postgis:9.6-alpine
image: postgis/postgis:16-3.5
env:
POSTGRES_DB: cormo_test
POSTGRES_USER: cormo_test
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ services:
- 21861:27017

postgres:
image: mdillon/postgis:9.6-alpine
image: postgis/postgis:16-3.5
environment:
POSTGRES_DB: cormo_test
POSTGRES_USER: cormo_test
Expand Down
52 changes: 36 additions & 16 deletions packages/cormo/test/cases/type_compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,38 +84,58 @@ export default function (models: { Type: typeof Type; connection: cormo.Connecti
});

it('compare string', async () => {
// string comparison is a little different between DBMSs
const data = [{ string: '1' }, { string: 'a' }, { string: 'A' }, { string: 'K' }];
await models.Type.createBulk(data);
let records = await models.Type.where({ string: 'a' });
// some adapters(currently, MySQL) may do case insensitive comparison.
// skip test for now
records.sort((a, b) => (a.string! < b.string! ? -1 : 1));
if (records.length === 2) {
return;
expect(records).to.have.length(2);
expect(records[0].string).to.equal('A');
expect(records[1].string).to.equal('a');
} else {
expect(records).to.have.length(1);
expect(records[0].string).to.equal('a');
}
expect(records).to.have.length(1);
expect(records[0].string).to.equal('a');
records = await models.Type.where({ string: { $lt: 'D' } });
expect(records).to.have.length(2);
records.sort((a, b) => (a.string! < b.string! ? -1 : 1));
expect(records[0].string).to.equal('1');
expect(records[1].string).to.equal('A');
if (records.length === 3) {
expect(records).to.have.length(3);
expect(records[0].string).to.equal('1');
expect(records[1].string).to.equal('A');
expect(records[2].string).to.equal('a');
} else {
expect(records).to.have.length(2);
expect(records[0].string).to.equal('1');
expect(records[1].string).to.equal('A');
}
});

it('compare text', async () => {
// string comparison is a little different between DBMSs
const data = [{ text: '1' }, { text: 'a' }, { text: 'A' }, { text: 'K' }];
await models.Type.createBulk(data);
let records = await models.Type.where({ text: 'a' });
// some adapters(currently, MySQL) may do case insensitive comparison.
// skip test for now
records.sort((a, b) => (a.text! < b.text! ? -1 : 1));
if (records.length === 2) {
return;
expect(records).to.have.length(2);
expect(records[0].text).to.equal('A');
expect(records[1].text).to.equal('a');
} else {
expect(records).to.have.length(1);
expect(records[0].text).to.equal('a');
}
expect(records).to.have.length(1);
expect(records[0].text).to.equal('a');
records = await models.Type.where({ text: { $lt: 'D' } });
expect(records).to.have.length(2);
records.sort((a, b) => (a.text! < b.text! ? -1 : 1));
expect(records[0].text).to.equal('1');
expect(records[1].text).to.equal('A');
if (records.length === 3) {
expect(records).to.have.length(3);
expect(records[0].text).to.equal('1');
expect(records[1].text).to.equal('A');
expect(records[2].text).to.equal('a');
} else {
expect(records).to.have.length(2);
expect(records[0].text).to.equal('1');
expect(records[1].text).to.equal('A');
}
});
}
2 changes: 0 additions & 2 deletions packages/cormo/test/support/common.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import path from 'path';
import url from 'url';
import * as cormo from '../../lib/esm/index.js';

const db_configs: { [db: string]: any } = {
Expand Down

0 comments on commit e1f17b7

Please sign in to comment.