Browse Source

chore: upgrade knex to v2.2.0

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/4280/head
mertmit 2 years ago
parent
commit
760aaf06aa
  1. 458
      packages/nocodb/package-lock.json
  2. 2
      packages/nocodb/package.json
  3. 2
      packages/nocodb/src/interface/config.ts
  4. 3
      packages/nocodb/src/lib/db/sql-client/lib/KnexClient.ts
  5. 12
      packages/nocodb/src/lib/db/sql-data-mapper/lib/BaseModel.ts
  6. 14
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSql.ts
  7. 8
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts
  8. 130
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/CustomKnex.ts
  9. 18
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts
  10. 2
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/genRollupSelect.ts
  11. 4
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/genRollupSelectv2.ts
  12. 4
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/mapFunctionName.ts
  13. 4
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/sortV2.ts
  14. 4
      packages/nocodb/src/lib/db/sql-mgr/v2/SqlMgrv2Trans.ts
  15. 2
      packages/nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts
  16. 2
      packages/nocodb/src/lib/meta/api/publicApis/publicDataApis.ts
  17. 2
      packages/nocodb/src/lib/migrations/v1/nc_002_add_m2m.ts
  18. 2
      packages/nocodb/src/lib/migrations/v1/nc_003_add_fkn_column.ts
  19. 2
      packages/nocodb/src/lib/migrations/v1/nc_004_add_view_type_column.ts
  20. 2
      packages/nocodb/src/lib/migrations/v1/nc_005_add_view_name_column.ts
  21. 2
      packages/nocodb/src/lib/migrations/v1/nc_006_alter_nc_shared_views.ts
  22. 2
      packages/nocodb/src/lib/migrations/v1/nc_007_alter_nc_shared_views_1.ts
  23. 2
      packages/nocodb/src/lib/migrations/v1/nc_008_add_nc_shared_bases.ts
  24. 2
      packages/nocodb/src/lib/migrations/v1/nc_009_add_model_order.ts
  25. 2
      packages/nocodb/src/lib/migrations/v1/nc_010_add_parent_title_column.ts
  26. 2
      packages/nocodb/src/lib/migrations/v1/nc_011_remove_old_ses_plugin.ts
  27. 2
      packages/nocodb/src/lib/migrations/v2/nc_012_alter_column_data_types.ts
  28. 2
      packages/nocodb/src/lib/migrations/v2/nc_013_sync_source.ts
  29. 2
      packages/nocodb/src/lib/migrations/v2/nc_014_alter_column_data_types.ts
  30. 2
      packages/nocodb/src/lib/migrations/v2/nc_015_add_meta_col_in_column_table.ts
  31. 2
      packages/nocodb/src/lib/migrations/v2/nc_016_alter_hooklog_payload_types.ts
  32. 2
      packages/nocodb/src/lib/migrations/v2/nc_017_add_user_token_version_column.ts
  33. 2
      packages/nocodb/src/lib/migrations/v2/nc_018_add_meta_in_view.ts
  34. 2
      packages/nocodb/src/lib/migrations/v2/nc_019_add_meta_in_meta_tables.ts
  35. 2
      packages/nocodb/src/lib/migrations/v2/nc_020_kanban_view.ts
  36. 2
      packages/nocodb/src/lib/utils/common/NcConnectionMgr.ts
  37. 6
      packages/nocodb/tests/unit/TestDbMngr.ts

458
packages/nocodb/package-lock.json generated

@ -52,7 +52,7 @@
"jsep": "^1.3.6",
"jsonfile": "^6.1.0",
"jsonwebtoken": "^8.5.1",
"knex": "^0.21.2",
"knex": "^2.2.0",
"lodash": "^4.17.19",
"lru-cache": "^6.0.0",
"mailersend": "^1.1.0",
@ -3563,9 +3563,9 @@
"integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw=="
},
"node_modules/colorette": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/colorette/-/colorette-1.2.1.tgz",
"integrity": "sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw=="
"version": "2.0.19",
"resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.19.tgz",
"integrity": "sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ=="
},
"node_modules/colors": {
"version": "1.4.0",
@ -4837,7 +4837,6 @@
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz",
"integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==",
"dev": true,
"engines": {
"node": ">=6"
}
@ -6420,17 +6419,6 @@
"node": ">= 0.10"
}
},
"node_modules/fined/node_modules/is-plain-object": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
"integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
"dependencies": {
"isobject": "^3.0.1"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/flagged-respawn": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-1.0.1.tgz",
@ -6916,6 +6904,14 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-package-type": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz",
"integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==",
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/get-port": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/get-port/-/get-port-5.1.1.tgz",
@ -6974,9 +6970,9 @@
}
},
"node_modules/getopts": {
"version": "2.2.5",
"resolved": "https://registry.npmjs.org/getopts/-/getopts-2.2.5.tgz",
"integrity": "sha512-9jb7AW5p3in+IiJWhQiZmmwkpLaR/ccTWdWQCtZM66HJcHHLegowh4q4tSD7gouUyeNvFWRavfK9GXosQHDpFA=="
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/getopts/-/getopts-2.3.0.tgz",
"integrity": "sha512-5eDf9fuSXwxBL6q5HX+dhDj+dslFGWzU5thZ9kNKUkcPtaPdatmUFKwHFrLb/uf/WpA4BHET+AX3Scl56cAjpA=="
},
"node_modules/getpass": {
"version": "0.1.7",
@ -8072,17 +8068,6 @@
"node": ">=0.10.0"
}
},
"node_modules/is-extendable/node_modules/is-plain-object": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
"integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
"dependencies": {
"isobject": "^3.0.1"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/is-extglob": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
@ -8186,6 +8171,17 @@
"node": ">=8"
}
},
"node_modules/is-plain-object": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
"integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
"dependencies": {
"isobject": "^3.0.1"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/is-potential-custom-element-name": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz",
@ -8910,38 +8906,33 @@
}
},
"node_modules/knex": {
"version": "0.21.21",
"resolved": "https://registry.npmjs.org/knex/-/knex-0.21.21.tgz",
"integrity": "sha512-cjw5qO1EzVKjbywcVa61IQJMLt7PfYBRI/2NwCA/B9beXgbw652wDNLz+JM+UKKNsfwprq0ugYqBYc9q4JN36A==",
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/knex/-/knex-2.3.0.tgz",
"integrity": "sha512-WMizPaq9wRMkfnwKXKXgBZeZFOSHGdtoSz5SaLAVNs3WRDfawt9O89T4XyH52PETxjV8/kRk0Yf+8WBEP/zbYw==",
"dependencies": {
"colorette": "1.2.1",
"commander": "^6.2.0",
"debug": "4.3.1",
"colorette": "2.0.19",
"commander": "^9.1.0",
"debug": "4.3.4",
"escalade": "^3.1.1",
"esm": "^3.2.25",
"getopts": "2.2.5",
"get-package-type": "^0.1.0",
"getopts": "2.3.0",
"interpret": "^2.2.0",
"liftoff": "3.1.0",
"lodash": "^4.17.20",
"pg-connection-string": "2.4.0",
"tarn": "^3.0.1",
"tildify": "2.0.0",
"v8flags": "^3.2.0"
"lodash": "^4.17.21",
"pg-connection-string": "2.5.0",
"rechoir": "^0.8.0",
"resolve-from": "^5.0.0",
"tarn": "^3.0.2",
"tildify": "2.0.0"
},
"bin": {
"knex": "bin/cli.js"
},
"engines": {
"node": ">=10"
},
"peerDependencies": {
"mssql": "^6.2.1",
"mysql": "^2.18.1",
"mysql2": "^2.1.0",
"pg": "^8.3.0",
"sqlite3": "^5.0.0"
"node": ">=12"
},
"peerDependenciesMeta": {
"mssql": {
"better-sqlite3": {
"optional": true
},
"mysql": {
@ -8953,40 +8944,33 @@
"pg": {
"optional": true
},
"pg-native": {
"optional": true
},
"sqlite3": {
"optional": true
},
"tedious": {
"optional": true
}
}
},
"node_modules/knex/node_modules/commander": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-6.2.1.tgz",
"integrity": "sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==",
"version": "9.4.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-9.4.1.tgz",
"integrity": "sha512-5EEkTNyHNGFPD2H+c/dXXfQZYa/scCKasxWcXJaWnNJ99pnQN9Vnmqow+p+PlFPE63Q6mThaZws1T+HxfpgtPw==",
"engines": {
"node": ">= 6"
"node": "^12.20.0 || >=14"
}
},
"node_modules/knex/node_modules/debug": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz",
"integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==",
"dependencies": {
"ms": "2.1.2"
},
"node_modules/knex/node_modules/resolve-from": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz",
"integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==",
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
"node": ">=8"
}
},
"node_modules/knex/node_modules/ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"node_modules/kuler": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/kuler/-/kuler-2.0.0.tgz",
@ -9079,15 +9063,15 @@
"node": ">= 0.8"
}
},
"node_modules/liftoff/node_modules/is-plain-object": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
"integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
"node_modules/liftoff/node_modules/rechoir": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz",
"integrity": "sha512-HFM8rkZ+i3zrV+4LQjwQ0W+ez98pApMGM3HUrN04j3CqzPOzl9nmP15Y8YXNm8QHGv/eacOVEjqhmWpkRV0NAw==",
"dependencies": {
"isobject": "^3.0.1"
"resolve": "^1.1.6"
},
"engines": {
"node": ">=0.10.0"
"node": ">= 0.10"
}
},
"node_modules/loader-runner": {
@ -10494,6 +10478,99 @@
"node": ">=8"
}
},
"node_modules/nc-help/node_modules/colorette": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/colorette/-/colorette-1.2.1.tgz",
"integrity": "sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw=="
},
"node_modules/nc-help/node_modules/commander": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-6.2.1.tgz",
"integrity": "sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==",
"engines": {
"node": ">= 6"
}
},
"node_modules/nc-help/node_modules/debug": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz",
"integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==",
"dependencies": {
"ms": "2.1.2"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
}
},
"node_modules/nc-help/node_modules/getopts": {
"version": "2.2.5",
"resolved": "https://registry.npmjs.org/getopts/-/getopts-2.2.5.tgz",
"integrity": "sha512-9jb7AW5p3in+IiJWhQiZmmwkpLaR/ccTWdWQCtZM66HJcHHLegowh4q4tSD7gouUyeNvFWRavfK9GXosQHDpFA=="
},
"node_modules/nc-help/node_modules/knex": {
"version": "0.21.21",
"resolved": "https://registry.npmjs.org/knex/-/knex-0.21.21.tgz",
"integrity": "sha512-cjw5qO1EzVKjbywcVa61IQJMLt7PfYBRI/2NwCA/B9beXgbw652wDNLz+JM+UKKNsfwprq0ugYqBYc9q4JN36A==",
"dependencies": {
"colorette": "1.2.1",
"commander": "^6.2.0",
"debug": "4.3.1",
"esm": "^3.2.25",
"getopts": "2.2.5",
"interpret": "^2.2.0",
"liftoff": "3.1.0",
"lodash": "^4.17.20",
"pg-connection-string": "2.4.0",
"tarn": "^3.0.1",
"tildify": "2.0.0",
"v8flags": "^3.2.0"
},
"bin": {
"knex": "bin/cli.js"
},
"engines": {
"node": ">=10"
},
"peerDependencies": {
"mssql": "^6.2.1",
"mysql": "^2.18.1",
"mysql2": "^2.1.0",
"pg": "^8.3.0",
"sqlite3": "^5.0.0"
},
"peerDependenciesMeta": {
"mssql": {
"optional": true
},
"mysql": {
"optional": true
},
"mysql2": {
"optional": true
},
"pg": {
"optional": true
},
"sqlite3": {
"optional": true
}
}
},
"node_modules/nc-help/node_modules/ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"node_modules/nc-help/node_modules/pg-connection-string": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.4.0.tgz",
"integrity": "sha512-3iBXuv7XKvxeMrIgym7njT+HlZkwZqqGX4Bu9cci8xHZNT+Um1gWKqCsAzcC0d95rcKMU5WBg6YRUcHyV0HZKQ=="
},
"node_modules/nc-help/node_modules/type-fest": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz",
@ -12277,9 +12354,9 @@
}
},
"node_modules/pg-connection-string": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.4.0.tgz",
"integrity": "sha512-3iBXuv7XKvxeMrIgym7njT+HlZkwZqqGX4Bu9cci8xHZNT+Um1gWKqCsAzcC0d95rcKMU5WBg6YRUcHyV0HZKQ=="
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.5.0.tgz",
"integrity": "sha512-r5o/V/ORTA6TmUnyWZR9nCj1klXCO2CEKNRlVuJptZe85QuhFayC7WeMic7ndayT5IRIR0S0xFxFi2ousartlQ=="
},
"node_modules/pg-int8": {
"version": "1.0.1",
@ -12317,11 +12394,6 @@
"node": ">=4"
}
},
"node_modules/pg/node_modules/pg-connection-string": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.5.0.tgz",
"integrity": "sha512-r5o/V/ORTA6TmUnyWZR9nCj1klXCO2CEKNRlVuJptZe85QuhFayC7WeMic7ndayT5IRIR0S0xFxFi2ousartlQ=="
},
"node_modules/pgpass": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.5.tgz",
@ -12829,14 +12901,14 @@
}
},
"node_modules/rechoir": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz",
"integrity": "sha512-HFM8rkZ+i3zrV+4LQjwQ0W+ez98pApMGM3HUrN04j3CqzPOzl9nmP15Y8YXNm8QHGv/eacOVEjqhmWpkRV0NAw==",
"version": "0.8.0",
"resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.8.0.tgz",
"integrity": "sha512-/vxpCXddiX8NGfGO/mTafwjq4aFa/71pvamip0++IQk3zG8cbCj0fifNPrjjF1XMXUne91jL9OoxmdykoEtifQ==",
"dependencies": {
"resolve": "^1.1.6"
"resolve": "^1.20.0"
},
"engines": {
"node": ">= 0.10"
"node": ">= 10.13.0"
}
},
"node_modules/redis-commands": {
@ -13470,17 +13542,6 @@
"node": ">=0.10.0"
}
},
"node_modules/set-value/node_modules/is-plain-object": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
"integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
"dependencies": {
"isobject": "^3.0.1"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/setimmediate": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz",
@ -20505,9 +20566,9 @@
}
},
"colorette": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/colorette/-/colorette-1.2.1.tgz",
"integrity": "sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw=="
"version": "2.0.19",
"resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.19.tgz",
"integrity": "sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ=="
},
"colors": {
"version": "1.4.0",
@ -21539,8 +21600,7 @@
"escalade": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz",
"integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==",
"dev": true
"integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw=="
},
"escape-goat": {
"version": "2.1.1",
@ -22752,16 +22812,6 @@
"object.defaults": "^1.1.0",
"object.pick": "^1.2.0",
"parse-filepath": "^1.0.1"
},
"dependencies": {
"is-plain-object": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
"integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
"requires": {
"isobject": "^3.0.1"
}
}
}
},
"flagged-respawn": {
@ -23153,6 +23203,11 @@
"has-symbols": "^1.0.3"
}
},
"get-package-type": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz",
"integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q=="
},
"get-port": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/get-port/-/get-port-5.1.1.tgz",
@ -23187,9 +23242,9 @@
"integrity": "sha512-Ln0UQDlxH1BapMu3GPtf7CuYNwRZf2gwCuPqbyG6pB8WfmFpzqcy4xtAaAMUhnNqjMKTiCPZG2oMT3YSx8U2NA=="
},
"getopts": {
"version": "2.2.5",
"resolved": "https://registry.npmjs.org/getopts/-/getopts-2.2.5.tgz",
"integrity": "sha512-9jb7AW5p3in+IiJWhQiZmmwkpLaR/ccTWdWQCtZM66HJcHHLegowh4q4tSD7gouUyeNvFWRavfK9GXosQHDpFA=="
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/getopts/-/getopts-2.3.0.tgz",
"integrity": "sha512-5eDf9fuSXwxBL6q5HX+dhDj+dslFGWzU5thZ9kNKUkcPtaPdatmUFKwHFrLb/uf/WpA4BHET+AX3Scl56cAjpA=="
},
"getpass": {
"version": "0.1.7",
@ -23990,16 +24045,6 @@
"integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==",
"requires": {
"is-plain-object": "^2.0.4"
},
"dependencies": {
"is-plain-object": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
"integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
"requires": {
"isobject": "^3.0.1"
}
}
}
},
"is-extglob": {
@ -24063,6 +24108,14 @@
"resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz",
"integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w=="
},
"is-plain-object": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
"integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
"requires": {
"isobject": "^3.0.1"
}
},
"is-potential-custom-element-name": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz",
@ -24620,41 +24673,35 @@
"integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw=="
},
"knex": {
"version": "0.21.21",
"resolved": "https://registry.npmjs.org/knex/-/knex-0.21.21.tgz",
"integrity": "sha512-cjw5qO1EzVKjbywcVa61IQJMLt7PfYBRI/2NwCA/B9beXgbw652wDNLz+JM+UKKNsfwprq0ugYqBYc9q4JN36A==",
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/knex/-/knex-2.3.0.tgz",
"integrity": "sha512-WMizPaq9wRMkfnwKXKXgBZeZFOSHGdtoSz5SaLAVNs3WRDfawt9O89T4XyH52PETxjV8/kRk0Yf+8WBEP/zbYw==",
"requires": {
"colorette": "1.2.1",
"commander": "^6.2.0",
"debug": "4.3.1",
"colorette": "2.0.19",
"commander": "^9.1.0",
"debug": "4.3.4",
"escalade": "^3.1.1",
"esm": "^3.2.25",
"getopts": "2.2.5",
"get-package-type": "^0.1.0",
"getopts": "2.3.0",
"interpret": "^2.2.0",
"liftoff": "3.1.0",
"lodash": "^4.17.20",
"pg-connection-string": "2.4.0",
"tarn": "^3.0.1",
"tildify": "2.0.0",
"v8flags": "^3.2.0"
"lodash": "^4.17.21",
"pg-connection-string": "2.5.0",
"rechoir": "^0.8.0",
"resolve-from": "^5.0.0",
"tarn": "^3.0.2",
"tildify": "2.0.0"
},
"dependencies": {
"commander": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-6.2.1.tgz",
"integrity": "sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA=="
},
"debug": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz",
"integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==",
"requires": {
"ms": "2.1.2"
}
"version": "9.4.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-9.4.1.tgz",
"integrity": "sha512-5EEkTNyHNGFPD2H+c/dXXfQZYa/scCKasxWcXJaWnNJ99pnQN9Vnmqow+p+PlFPE63Q6mThaZws1T+HxfpgtPw=="
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
"resolve-from": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz",
"integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw=="
}
}
},
@ -24737,12 +24784,12 @@
"resolve": "^1.1.7"
},
"dependencies": {
"is-plain-object": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
"integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
"rechoir": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz",
"integrity": "sha512-HFM8rkZ+i3zrV+4LQjwQ0W+ez98pApMGM3HUrN04j3CqzPOzl9nmP15Y8YXNm8QHGv/eacOVEjqhmWpkRV0NAw==",
"requires": {
"isobject": "^3.0.1"
"resolve": "^1.1.6"
}
}
}
@ -25886,6 +25933,58 @@
"supports-color": "^7.1.0"
}
},
"colorette": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/colorette/-/colorette-1.2.1.tgz",
"integrity": "sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw=="
},
"commander": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-6.2.1.tgz",
"integrity": "sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA=="
},
"debug": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz",
"integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==",
"requires": {
"ms": "2.1.2"
}
},
"getopts": {
"version": "2.2.5",
"resolved": "https://registry.npmjs.org/getopts/-/getopts-2.2.5.tgz",
"integrity": "sha512-9jb7AW5p3in+IiJWhQiZmmwkpLaR/ccTWdWQCtZM66HJcHHLegowh4q4tSD7gouUyeNvFWRavfK9GXosQHDpFA=="
},
"knex": {
"version": "0.21.21",
"resolved": "https://registry.npmjs.org/knex/-/knex-0.21.21.tgz",
"integrity": "sha512-cjw5qO1EzVKjbywcVa61IQJMLt7PfYBRI/2NwCA/B9beXgbw652wDNLz+JM+UKKNsfwprq0ugYqBYc9q4JN36A==",
"requires": {
"colorette": "1.2.1",
"commander": "^6.2.0",
"debug": "4.3.1",
"esm": "^3.2.25",
"getopts": "2.2.5",
"interpret": "^2.2.0",
"liftoff": "3.1.0",
"lodash": "^4.17.20",
"pg-connection-string": "2.4.0",
"tarn": "^3.0.1",
"tildify": "2.0.0",
"v8flags": "^3.2.0"
}
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"pg-connection-string": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.4.0.tgz",
"integrity": "sha512-3iBXuv7XKvxeMrIgym7njT+HlZkwZqqGX4Bu9cci8xHZNT+Um1gWKqCsAzcC0d95rcKMU5WBg6YRUcHyV0HZKQ=="
},
"type-fest": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz",
@ -27284,19 +27383,12 @@
"pg-protocol": "^1.5.0",
"pg-types": "^2.1.0",
"pgpass": "1.x"
},
"dependencies": {
"pg-connection-string": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.5.0.tgz",
"integrity": "sha512-r5o/V/ORTA6TmUnyWZR9nCj1klXCO2CEKNRlVuJptZe85QuhFayC7WeMic7ndayT5IRIR0S0xFxFi2ousartlQ=="
}
}
},
"pg-connection-string": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.4.0.tgz",
"integrity": "sha512-3iBXuv7XKvxeMrIgym7njT+HlZkwZqqGX4Bu9cci8xHZNT+Um1gWKqCsAzcC0d95rcKMU5WBg6YRUcHyV0HZKQ=="
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.5.0.tgz",
"integrity": "sha512-r5o/V/ORTA6TmUnyWZR9nCj1klXCO2CEKNRlVuJptZe85QuhFayC7WeMic7ndayT5IRIR0S0xFxFi2ousartlQ=="
},
"pg-int8": {
"version": "1.0.1",
@ -27706,11 +27798,11 @@
"integrity": "sha512-gNva8/6UAe8QYepIQH/jQ2qn91Qj0B9sYjMBBs3QOB8F2CXcKgLxQaJRP76sWVRQt+QU+8fAkCbCvjjMFu7Ycw=="
},
"rechoir": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz",
"integrity": "sha512-HFM8rkZ+i3zrV+4LQjwQ0W+ez98pApMGM3HUrN04j3CqzPOzl9nmP15Y8YXNm8QHGv/eacOVEjqhmWpkRV0NAw==",
"version": "0.8.0",
"resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.8.0.tgz",
"integrity": "sha512-/vxpCXddiX8NGfGO/mTafwjq4aFa/71pvamip0++IQk3zG8cbCj0fifNPrjjF1XMXUne91jL9OoxmdykoEtifQ==",
"requires": {
"resolve": "^1.1.6"
"resolve": "^1.20.0"
}
},
"redis-commands": {
@ -28197,14 +28289,6 @@
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz",
"integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw=="
},
"is-plain-object": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
"integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
"requires": {
"isobject": "^3.0.1"
}
}
}
},

2
packages/nocodb/package.json

@ -95,7 +95,7 @@
"jsep": "^1.3.6",
"jsonfile": "^6.1.0",
"jsonwebtoken": "^8.5.1",
"knex": "^0.21.2",
"knex": "^2.2.0",
"lodash": "^4.17.19",
"lru-cache": "^6.0.0",
"mailersend": "^1.1.0",

2
packages/nocodb/src/interface/config.ts

@ -1,6 +1,6 @@
import { Handler } from 'express';
import * as e from 'express';
import Knex from 'knex';
import { Knex } from 'knex';
export interface Route {
path: string;

3
packages/nocodb/src/lib/db/sql-client/lib/KnexClient.ts

@ -1,10 +1,9 @@
/* eslint-disable no-constant-condition */
import Knex from 'knex';
import { knex, Knex } from 'knex'
import Debug from '../../util/Debug';
import Emit from '../../util/emit';
import Result from '../../util/Result';
import knex from 'knex';
import lodash from 'lodash';
import fs from 'fs';
import { promisify } from 'util';

12
packages/nocodb/src/lib/db/sql-data-mapper/lib/BaseModel.ts

@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/ban-types,prefer-const */
import Knex from 'knex';
import { Knex } from 'knex';
import Filter from '../../../models/Filter';
import Sort from '../../../models/Sort';
@ -112,7 +112,7 @@ abstract class BaseModel {
timeout: 25000,
};
this.clientType = this.dbDriver.clientType();
this.clientType = this.dbDriver.client;
autoBind(this);
}
@ -221,8 +221,8 @@ abstract class BaseModel {
const query = this.$db.insert(data);
if (
this.dbDriver.clientType() === 'pg' ||
this.dbDriver.clientType() === 'mssql'
this.dbDriver.client === 'pg' ||
this.dbDriver.client === 'mssql'
) {
query.returning('*');
response = await this._run(query);
@ -266,8 +266,8 @@ abstract class BaseModel {
const query = this.$db.insert(data);
if (
this.dbDriver.clientType() === 'pg' ||
this.dbDriver.clientType() === 'mssql'
this.dbDriver.client === 'pg' ||
this.dbDriver.client === 'mssql'
) {
query.returning('*');
response = await this._run(query);

14
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSql.ts

@ -89,7 +89,7 @@ class BaseModelSql extends BaseModel {
timeout: 25000,
};
this.clientType = this.dbDriver.clientType();
this.clientType = this.dbDriver.client;
this.dbModels = dbModels;
this._tn = _tn;
autoBind(this);
@ -281,7 +281,7 @@ class BaseModelSql extends BaseModel {
const query = driver(this.tnPath).insert(insertObj);
if (this.isPg() || this.dbDriver.clientType() === 'mssql') {
if (this.isPg() || this.dbDriver.client === 'mssql') {
query.returning(
Object.entries(this.aliasToColumn).map(
([val, key]) => `${key} as ${val}`
@ -332,7 +332,7 @@ class BaseModelSql extends BaseModel {
}
private isPg() {
return this.dbDriver.clientType() === 'pg';
return this.dbDriver.client === 'pg';
}
/**
@ -418,8 +418,8 @@ class BaseModelSql extends BaseModel {
const query = dbDriver(this.tnPath).insert(insertObj);
if (
this.dbDriver.clientType() === 'pg' ||
this.dbDriver.clientType() === 'mssql'
this.dbDriver.client === 'pg' ||
this.dbDriver.client === 'mssql'
) {
query.returning(this.selectQuery(''));
response = await this._run(query);
@ -1708,7 +1708,7 @@ class BaseModelSql extends BaseModel {
const query = driver(this.tnPath).insert(insertObj);
if (this.isPg() || this.dbDriver.clientType() === 'mssql') {
if (this.isPg() || this.dbDriver.client === 'mssql') {
query.returning(
Object.entries(this.aliasToColumn).map(
([val, key]) => `${key} as ${val}`
@ -2096,7 +2096,7 @@ class BaseModelSql extends BaseModel {
}
isMssql() {
return this.dbDriver.clientType() === 'mssql';
return this.dbDriver.client === 'mssql';
}
/**

8
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts

@ -17,7 +17,7 @@ import Sort from '../../../../models/Sort';
import FormulaColumn from '../../../../models/FormulaColumn';
import genRollupSelectv2 from './genRollupSelectv2';
import formulaQueryBuilderv2 from './formulav2/formulaQueryBuilderv2';
import { QueryBuilder } from 'knex';
import { Knex } from 'knex';
import View from '../../../../models/View';
import {
AuditOperationSubTypes,
@ -1336,7 +1336,7 @@ class BaseModelSqlv2 {
return obj;
}
public async shuffle({ qb }: { qb: QueryBuilder }): Promise<void> {
public async shuffle({ qb }: { qb: Knex.QueryBuilder }): Promise<void> {
if (this.isMySQL) {
qb.orderByRaw('RAND()');
} else if (this.isPg || this.isSqlite) {
@ -1350,7 +1350,7 @@ class BaseModelSqlv2 {
qb,
columns: _columns,
}: {
qb: QueryBuilder;
qb: Knex.QueryBuilder;
columns?: Column[];
}): Promise<void> {
const res = {};
@ -2629,7 +2629,7 @@ class BaseModelSqlv2 {
return await qb;
}
private async extractRawQueryAndExec(qb: QueryBuilder) {
private async extractRawQueryAndExec(qb: Knex.QueryBuilder) {
let query = qb.toQuery();
if (!this.isPg && !this.isMssql) {
query = unsanitize(qb.toQuery());

130
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/CustomKnex.ts

@ -1,4 +1,4 @@
import Knex, { QueryBuilder } from 'knex';
import { Knex, knex } from 'knex';
const types = require('pg').types;
// override parsing date column to Date()
@ -464,70 +464,72 @@ const appendWhereCondition = function (
};
declare module 'knex' {
interface QueryInterface {
clientType(): string;
}
export type XcConditionObjVal = {
[key in 'eq' | 'neq' | 'lt' | 'gt' | 'ge' | 'le' | 'like' | 'nlike']:
| string
| number
| any;
};
export interface XcXonditionObj {
_or: XcXonditionObj[];
_and: XcXonditionObj[];
_not: XcXonditionObj;
namespace Knex {
interface QueryInterface {
clientType(): string;
}
[key: string]:
| XcXonditionObj
| XcXonditionObj[]
| XcConditionObjVal
| XcConditionObjVal[];
}
export type XcConditionObjVal = {
[key in 'eq' | 'neq' | 'lt' | 'gt' | 'ge' | 'le' | 'like' | 'nlike']:
| string
| number
| any;
};
export interface XcXonditionObj {
_or: XcXonditionObj[];
_and: XcXonditionObj[];
_not: XcXonditionObj;
[key: string]:
| XcXonditionObj
| XcXonditionObj[]
| XcConditionObjVal
| XcConditionObjVal[];
}
interface QueryBuilder {
xwhere<TRecord, TResult>(
value: string,
columnAliases?: {
[columnAlias: string]: string;
}
): Knex.QueryBuilder<TRecord, TResult>;
interface QueryBuilder {
xwhere<TRecord, TResult>(
value: string,
columnAliases?: {
[columnAlias: string]: string;
}
): Knex.QueryBuilder<TRecord, TResult>;
condition<TRecord, TResult>(
conditionObj: XcXonditionObj,
columnAliases?: {
[columnAlias: string]: string;
}
): Knex.QueryBuilder<TRecord, TResult>;
condition<TRecord, TResult>(
conditionObj: XcXonditionObj,
columnAliases?: {
[columnAlias: string]: string;
}
): Knex.QueryBuilder<TRecord, TResult>;
conditionv2<TRecord, TResult>(
conditionObj: Filter
): Knex.QueryBuilder<TRecord, TResult>;
conditionv2<TRecord, TResult>(
conditionObj: Filter
): Knex.QueryBuilder<TRecord, TResult>;
concat<TRecord, TResult>(
cn: string | any
): Knex.QueryBuilder<TRecord, TResult>;
concat<TRecord, TResult>(
cn: string | any
): Knex.QueryBuilder<TRecord, TResult>;
conditionGraph<TRecord, TResult>(condition: {
condition: XcXonditionObj;
models: { [key: string]: BaseModelSql };
}): Knex.QueryBuilder<TRecord, TResult>;
conditionGraph<TRecord, TResult>(condition: {
condition: XcXonditionObj;
models: { [key: string]: BaseModelSql };
}): Knex.QueryBuilder<TRecord, TResult>;
xhaving<TRecord, TResult>(
value: string,
columnAliases?: {
[columnAlias: string]: string;
}
): Knex.QueryBuilder<TRecord, TResult>;
xhaving<TRecord, TResult>(
value: string,
columnAliases?: {
[columnAlias: string]: string;
}
): Knex.QueryBuilder<TRecord, TResult>;
}
}
}
/**
* Append xwhere to knex query builder
*/
Knex.QueryBuilder.extend(
knex.QueryBuilder.extend(
'xwhere',
function (
conditionString,
@ -542,7 +544,7 @@ Knex.QueryBuilder.extend(
/**
* Append concat to knex query builder
*/
Knex.QueryBuilder.extend('concat', function (cn: any) {
knex.QueryBuilder.extend('concat', function (cn: any) {
switch (this?.client?.config?.client) {
case 'pg':
this.select(this.client.raw(`STRING_AGG(?? , ',')`, [cn]));
@ -564,7 +566,7 @@ Knex.QueryBuilder.extend('concat', function (cn: any) {
/**
* Append xhaving to knex query builder
*/
Knex.QueryBuilder.extend(
knex.QueryBuilder.extend(
'xhaving',
function (
conditionString,
@ -580,7 +582,7 @@ Knex.QueryBuilder.extend(
/**
* Append custom where condition(nested object) to knex query builder
*/
Knex.QueryBuilder.extend('condition', function (conditionObj, columnAliases) {
knex.QueryBuilder.extend('condition', function (conditionObj, columnAliases) {
if (!conditionObj || typeof conditionObj !== 'object') {
return this;
}
@ -661,7 +663,7 @@ const parseCondition = (obj, columnAliases, qb, pKey?) => {
};
// todo: optimize
Knex.QueryBuilder.extend(
knex.QueryBuilder.extend(
'conditionGraph',
function (args: { condition; models }) {
if (!args) {
@ -986,9 +988,9 @@ function parseNestedCondition(obj, qb, pKey?, table?, tableAlias?) {
type CustomKnex = Knex;
function CustomKnex(arg: string | Knex.Config<any> | any): CustomKnex {
const knex: any = Knex(arg);
const kn: any = knex(arg);
const knexRaw = knex.raw;
const knexRaw = kn.raw;
/**
* Wrapper for knex.raw
@ -1000,11 +1002,11 @@ function CustomKnex(arg: string | Knex.Config<any> | any): CustomKnex {
// return knexRaw.apply(knex, args);
// };
Object.defineProperties(knex, {
Object.defineProperties(kn, {
raw: {
enumerable: true,
value: (...args) => {
return knexRaw.apply(knex, args);
return knexRaw.apply(kn, args);
},
},
clientType: {
@ -1032,11 +1034,11 @@ function CustomKnex(arg: string | Knex.Config<any> | any): CustomKnex {
// return typeof arg === 'string' ? arg.match(/^(\w+):/) ?? [1] : arg.client;
// };
return knex;
return kn;
}
// todo: optimize
Knex.QueryBuilder.extend(
knex.QueryBuilder.extend(
'conditionGraphv2',
function (args: { condition; models }) {
if (!args) {
@ -1227,14 +1229,14 @@ function parseNestedConditionv2(obj, qb, pKey?, table?, tableAlias?) {
/**
* Append custom where condition(nested object) to knex query builder
*/
Knex.QueryBuilder.extend('conditionv2', function (conditionObj: Filter) {
knex.QueryBuilder.extend('conditionv2', function (conditionObj: Filter) {
if (!conditionObj || typeof conditionObj !== 'object') {
return this;
}
return parseConditionv2(conditionObj, this);
} as any);
const parseConditionv2 = (obj: Filter, qb: QueryBuilder) => {
const parseConditionv2 = (obj: Filter, qb: Knex.QueryBuilder) => {
if (obj.is_group) {
qb = qb.where(function () {
const children = obj.children;

18
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts

@ -1,6 +1,6 @@
import Filter from '../../../../models/Filter';
import LinkToAnotherRecordColumn from '../../../../models/LinkToAnotherRecordColumn';
import { QueryBuilder } from 'knex';
import { Knex } from 'knex';
import { XKnex } from '../../index';
import Column from '../../../../models/Column';
import LookupColumn from '../../../../models/LookupColumn';
@ -14,7 +14,7 @@ import { sanitize } from './helpers/sanitize';
export default async function conditionV2(
conditionObj: Filter | Filter[],
qb: QueryBuilder,
qb: Knex.QueryBuilder,
knex: XKnex
) {
if (!conditionObj || typeof conditionObj !== 'object') {
@ -127,7 +127,7 @@ const parseConditionV2 = async (
)
)(selectQb);
return (qbP: QueryBuilder) => {
return (qbP: Knex.QueryBuilder) => {
if (filter.comparison_op in negatedMapping)
qbP.whereNotIn(parentColumn.column_name, selectQb);
else qbP.whereIn(parentColumn.column_name, selectQb);
@ -162,7 +162,7 @@ const parseConditionV2 = async (
)
)(selectQb);
return (qbP: QueryBuilder) => {
return (qbP: Knex.QueryBuilder) => {
if (filter.comparison_op in negatedMapping)
qbP.whereNotIn(childColumn.column_name, selectQb);
else qbP.whereIn(childColumn.column_name, selectQb);
@ -217,7 +217,7 @@ const parseConditionV2 = async (
)
)(selectQb);
return (qbP: QueryBuilder) => {
return (qbP: Knex.QueryBuilder) => {
if (filter.comparison_op in negatedMapping)
qbP.whereNotIn(childColumn.column_name, selectQb);
else qbP.whereIn(childColumn.column_name, selectQb);
@ -428,7 +428,7 @@ async function generateLookupCondition(
aliasCount
);
return (qbP: QueryBuilder) => {
return (qbP: Knex.QueryBuilder) => {
if (filter.comparison_op in negatedMapping)
qbP.whereNotIn(parentColumn.column_name, qb);
else qbP.whereIn(parentColumn.column_name, qb);
@ -451,7 +451,7 @@ async function generateLookupCondition(
aliasCount
);
return (qbP: QueryBuilder) => {
return (qbP: Knex.QueryBuilder) => {
if (filter.comparison_op in negatedMapping)
qbP.whereNotIn(childColumn.column_name, qb);
else qbP.whereIn(childColumn.column_name, qb);
@ -485,7 +485,7 @@ async function generateLookupCondition(
aliasCount
);
return (qbP: QueryBuilder) => {
return (qbP: Knex.QueryBuilder) => {
if (filter.comparison_op in negatedMapping)
qbP.whereNotIn(childColumn.column_name, qb);
else qbP.whereIn(childColumn.column_name, qb);
@ -497,7 +497,7 @@ async function generateLookupCondition(
async function nestedConditionJoin(
filter: Filter,
lookupColumn: Column,
qb: QueryBuilder,
qb: Knex.QueryBuilder,
knex,
alias: string,
aliasCount: { count: number }

2
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/genRollupSelect.ts

@ -1,4 +1,4 @@
import Knex from 'knex';
import { Knex } from 'knex';
import { RelationTypes } from 'nocodb-sdk';
export default function ({

4
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/genRollupSelectv2.ts

@ -1,7 +1,7 @@
import RollupColumn from '../../../../models/RollupColumn';
import { XKnex } from '../../index';
import LinkToAnotherRecordColumn from '../../../../models/LinkToAnotherRecordColumn';
import { QueryBuilder } from 'knex';
import { Knex } from 'knex';
import { RelationTypes } from 'nocodb-sdk';
export default async function ({
@ -14,7 +14,7 @@ export default async function ({
knex: XKnex;
alias?: string;
columnOptions: RollupColumn;
}): Promise<{ builder: QueryBuilder | any }> {
}): Promise<{ builder: Knex.QueryBuilder | any }> {
const relationColumn = await columnOptions.getRelationColumn();
const relationColumnOption: LinkToAnotherRecordColumn =
(await relationColumn.getColOptions()) as LinkToAnotherRecordColumn;

4
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/mapFunctionName.ts

@ -3,7 +3,7 @@ import mssql from './functionMappings/mssql';
import mysql from './functionMappings/mysql';
import pg from './functionMappings/pg';
import sqlite from './functionMappings/sqlite';
import { QueryBuilder } from 'knex';
import { Knex } from 'knex';
export interface MapFnArgs {
pt: any;
@ -11,7 +11,7 @@ export interface MapFnArgs {
knex: XKnex;
alias: string;
a?: string;
fn: (...args: any) => QueryBuilder | any;
fn: (...args: any) => Knex.QueryBuilder | any;
colAlias: string;
prevBinaryOp?: any;
}

4
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/sortV2.ts

@ -1,4 +1,4 @@
import { QueryBuilder } from 'knex';
import { Knex } from 'knex';
import { XKnex } from '../../index';
import Sort from '../../../../models/Sort';
import LinkToAnotherRecordColumn from '../../../../models/LinkToAnotherRecordColumn';
@ -12,7 +12,7 @@ import { sanitize } from './helpers/sanitize';
export default async function sortV2(
sortList: Sort[],
qb: QueryBuilder,
qb: Knex.QueryBuilder,
knex: XKnex
) {
if (!sortList?.length) {

4
packages/nocodb/src/lib/db/sql-mgr/v2/SqlMgrv2Trans.ts

@ -1,13 +1,13 @@
import SqlMgrv2 from './SqlMgrv2';
import Base from '../../../models/Base';
import NcConnectionMgrv2 from '../../../utils/common/NcConnectionMgrv2';
import { Transaction } from 'knex';
import { Knex } from 'knex';
import { XKnex } from '../../sql-data-mapper';
import NcMetaIO from '../../../meta/NcMetaIO';
import KnexMigratorv2Tans from '../../sql-migrator/lib/KnexMigratorv2Tans';
export default class SqlMgrv2Trans extends SqlMgrv2 {
protected trx: Transaction;
protected trx: Knex.Transaction;
protected ncMeta: NcMetaIO;
protected projectId: string;
protected base: Base;

2
packages/nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts

@ -270,7 +270,7 @@ async function getGroupedDataList(model, view: View, req) {
data = data.map((item) => {
// todo: use map to avoid loop
const count =
countArr.find((countItem) => countItem.key === item.key)?.count ?? 0;
countArr.find((countItem: any) => countItem.key === item.key)?.count ?? 0;
item.value = new PagedResponseImpl(item.value, {
...req.query,

2
packages/nocodb/src/lib/meta/api/publicApis/publicDataApis.ts

@ -157,7 +157,7 @@ async function getGroupedDataList(model, view: View, req) {
data = data.map((item) => {
// todo: use map to avoid loop
const count =
countArr.find((countItem) => countItem.key === item.key)?.count ?? 0;
countArr.find((countItem: any) => countItem.key === item.key)?.count ?? 0;
item.value = new PagedResponseImpl(item.value, {
...req.query,

2
packages/nocodb/src/lib/migrations/v1/nc_002_add_m2m.ts

@ -1,4 +1,4 @@
import Knex from 'knex';
import { Knex } from 'knex';
const up = async (knex: Knex) => {
await knex.schema.alterTable('nc_models', (table) => {

2
packages/nocodb/src/lib/migrations/v1/nc_003_add_fkn_column.ts

@ -1,4 +1,4 @@
import Knex from 'knex';
import { Knex } from 'knex';
const up = async (knex: Knex) => {
await knex.schema.alterTable('nc_relations', (table) => {

2
packages/nocodb/src/lib/migrations/v1/nc_004_add_view_type_column.ts

@ -1,4 +1,4 @@
import Knex from 'knex';
import { Knex } from 'knex';
const up = async (knex: Knex) => {
await knex.schema.alterTable('nc_shared_views', (table) => {

2
packages/nocodb/src/lib/migrations/v1/nc_005_add_view_name_column.ts

@ -1,4 +1,4 @@
import Knex from 'knex';
import { Knex } from 'knex';
const up = async (knex: Knex) => {
await knex.schema.alterTable('nc_shared_views', (table) => {

2
packages/nocodb/src/lib/migrations/v1/nc_006_alter_nc_shared_views.ts

@ -1,4 +1,4 @@
import Knex from 'knex';
import { Knex } from 'knex';
const up = async (knex: Knex) => {
await knex.schema.alterTable('nc_shared_views', (table) => {

2
packages/nocodb/src/lib/migrations/v1/nc_007_alter_nc_shared_views_1.ts

@ -1,4 +1,4 @@
import Knex from 'knex';
import { Knex } from 'knex';
const up = async (knex: Knex) => {
await knex.schema.alterTable('nc_shared_views', (table) => {

2
packages/nocodb/src/lib/migrations/v1/nc_008_add_nc_shared_bases.ts

@ -1,4 +1,4 @@
import Knex from 'knex';
import { Knex } from 'knex';
const up = async (knex: Knex) => {
await knex.schema.createTable('nc_shared_bases', (table) => {

2
packages/nocodb/src/lib/migrations/v1/nc_009_add_model_order.ts

@ -1,4 +1,4 @@
import Knex from 'knex';
import { Knex } from 'knex';
const up = async (knex: Knex) => {
await knex.schema.alterTable('nc_models', (table) => {

2
packages/nocodb/src/lib/migrations/v1/nc_010_add_parent_title_column.ts

@ -1,4 +1,4 @@
import Knex from 'knex';
import { Knex } from 'knex';
const up = async (knex: Knex) => {
await knex.schema.alterTable('nc_disabled_models_for_role', (table) => {

2
packages/nocodb/src/lib/migrations/v1/nc_011_remove_old_ses_plugin.ts

@ -1,4 +1,4 @@
import Knex from 'knex';
import { Knex } from 'knex';
import ses from '../../v1-legacy/plugins/ses';
const up = async (knex: Knex) => {

2
packages/nocodb/src/lib/migrations/v2/nc_012_alter_column_data_types.ts

@ -1,4 +1,4 @@
import Knex from 'knex';
import { Knex } from 'knex';
import { MetaTable } from '../../utils/globals';
const up = async (knex: Knex) => {

2
packages/nocodb/src/lib/migrations/v2/nc_013_sync_source.ts

@ -1,4 +1,4 @@
import Knex from 'knex';
import { Knex } from 'knex';
import { MetaTable } from '../../utils/globals';
const up = async (knex: Knex) => {

2
packages/nocodb/src/lib/migrations/v2/nc_014_alter_column_data_types.ts

@ -1,4 +1,4 @@
import Knex from 'knex';
import { Knex } from 'knex';
import { MetaTable } from '../../utils/globals';
const up = async (knex: Knex) => {

2
packages/nocodb/src/lib/migrations/v2/nc_015_add_meta_col_in_column_table.ts

@ -1,4 +1,4 @@
import Knex from 'knex';
import { Knex } from 'knex';
import { MetaTable } from '../../utils/globals';
const up = async (knex: Knex) => {

2
packages/nocodb/src/lib/migrations/v2/nc_016_alter_hooklog_payload_types.ts

@ -1,4 +1,4 @@
import Knex from 'knex';
import { Knex } from 'knex';
import { MetaTable } from '../../utils/globals';
const up = async (knex: Knex) => {

2
packages/nocodb/src/lib/migrations/v2/nc_017_add_user_token_version_column.ts

@ -1,4 +1,4 @@
import Knex from 'knex';
import { Knex } from 'knex';
const up = async (knex: Knex) => {
await knex.schema.alterTable('nc_users_v2', (table) => {

2
packages/nocodb/src/lib/migrations/v2/nc_018_add_meta_in_view.ts

@ -1,4 +1,4 @@
import Knex from 'knex';
import { Knex } from 'knex';
import { MetaTable } from '../../utils/globals';
const up = async (knex: Knex) => {

2
packages/nocodb/src/lib/migrations/v2/nc_019_add_meta_in_meta_tables.ts

@ -1,4 +1,4 @@
import Knex from 'knex';
import { Knex } from 'knex';
import { MetaTable } from '../../utils/globals';
const up = async (knex: Knex) => {

2
packages/nocodb/src/lib/migrations/v2/nc_020_kanban_view.ts

@ -1,4 +1,4 @@
import Knex from 'knex';
import { Knex } from 'knex';
import { MetaTable } from '../../utils/globals';
const up = async (knex: Knex) => {

2
packages/nocodb/src/lib/utils/common/NcConnectionMgr.ts

@ -2,7 +2,7 @@ import SqlClientFactory from '../../db/sql-client/lib/SqlClientFactory';
import { XKnex } from '../../db/sql-data-mapper';
import { NcConfig } from '../../../interface/config';
import fs from 'fs';
import Knex from 'knex';
import { Knex } from 'knex';
import NcMetaIO from '../../meta/NcMetaIO';
import { defaultConnectionConfig } from '../NcConfigFactory';

6
packages/nocodb/tests/unit/TestDbMngr.ts

@ -2,14 +2,14 @@ import { DbConfig } from "../../src/interface/config";
import { NcConfigFactory } from "../../src/lib";
import SqlMgrv2 from "../../src/lib/db/sql-mgr/v2/SqlMgrv2";
import fs from 'fs';
import knex from "knex";
import { Knex, knex } from "knex";
import process from "process";
export default class TestDbMngr {
public static readonly dbName = 'test_meta';
public static readonly sakilaDbName = 'test_sakila';
public static metaKnex: knex;
public static sakilaKnex: knex;
public static metaKnex: Knex;
public static sakilaKnex: Knex;
public static defaultConnection = {
user: 'root',

Loading…
Cancel
Save