Browse Source

0.90.5 Pre-release (#1774)

* chore(deps): bump minimist

Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore(deps): bump async from 2.6.3 to 2.6.4 in /packages/noco-docs-prev

Bumps [async](https://github.com/caolan/async) from 2.6.3 to 2.6.4.
- [Release notes](https://github.com/caolan/async/releases)
- [Changelog](https://github.com/caolan/async/blob/v2.6.4/CHANGELOG.md)
- [Commits](https://github.com/caolan/async/compare/v2.6.3...v2.6.4)

---
updated-dependencies:
- dependency-name: async
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore(deps): bump async from 2.6.3 to 2.6.4 in /packages/noco-docs

Bumps [async](https://github.com/caolan/async) from 2.6.3 to 2.6.4.
- [Release notes](https://github.com/caolan/async/releases)
- [Changelog](https://github.com/caolan/async/blob/v2.6.4/CHANGELOG.md)
- [Commits](https://github.com/caolan/async/compare/v2.6.3...v2.6.4)

---
updated-dependencies:
- dependency-name: async
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore(deps): bump async from 2.6.3 to 2.6.4 in /packages/nc-plugin

Bumps [async](https://github.com/caolan/async) from 2.6.3 to 2.6.4.
- [Release notes](https://github.com/caolan/async/releases)
- [Changelog](https://github.com/caolan/async/blob/v2.6.4/CHANGELOG.md)
- [Commits](https://github.com/caolan/async/compare/v2.6.3...v2.6.4)

---
updated-dependencies:
- dependency-name: async
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore(deps): bump async from 2.6.3 to 2.6.4 in /packages/nc-cli

Bumps [async](https://github.com/caolan/async) from 2.6.3 to 2.6.4.
- [Release notes](https://github.com/caolan/async/releases)
- [Changelog](https://github.com/caolan/async/blob/v2.6.4/CHANGELOG.md)
- [Commits](https://github.com/caolan/async/compare/v2.6.3...v2.6.4)

---
updated-dependencies:
- dependency-name: async
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore(deps): bump async from 2.6.3 to 2.6.4 in /packages/noco-i18n

Bumps [async](https://github.com/caolan/async) from 2.6.3 to 2.6.4.
- [Release notes](https://github.com/caolan/async/releases)
- [Changelog](https://github.com/caolan/async/blob/v2.6.4/CHANGELOG.md)
- [Commits](https://github.com/caolan/async/compare/v2.6.3...v2.6.4)

---
updated-dependencies:
- dependency-name: async
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore(deps): bump async from 2.6.3 to 2.6.4 in /packages/noco-blog

Bumps [async](https://github.com/caolan/async) from 2.6.3 to 2.6.4.
- [Release notes](https://github.com/caolan/async/releases)
- [Changelog](https://github.com/caolan/async/blob/v2.6.4/CHANGELOG.md)
- [Commits](https://github.com/caolan/async/compare/v2.6.3...v2.6.4)

---
updated-dependencies:
- dependency-name: async
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore(deps): bump async from 2.6.3 to 2.6.4 in /packages/nocodb-sdk

Bumps [async](https://github.com/caolan/async) from 2.6.3 to 2.6.4.
- [Release notes](https://github.com/caolan/async/releases)
- [Changelog](https://github.com/caolan/async/blob/v2.6.4/CHANGELOG.md)
- [Commits](https://github.com/caolan/async/compare/v2.6.3...v2.6.4)

---
updated-dependencies:
- dependency-name: async
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore(deps): bump minimist from 1.2.5 to 1.2.6 in /packages/nocodb

Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* refactor: i18n zh_CN corrections

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>

* refactor: use SqlFactory from nocodb-sdk package (#1750)

Signed-off-by: Pranav C <pranavxc@gmail.com>

* fix: refer parent table referenced column in filter query(BT)

re #1756

Signed-off-by: Pranav C <pranavxc@gmail.com>

* fix: wrap nested add update query select part to avoid issue when referencing same table

Signed-off-by: Pranav C <pranavxc@gmail.com>

* chore(deps): bump async in /packages/nc-migrator-archived

Bumps [async](https://github.com/caolan/async) from 2.6.2 to 2.6.4.
- [Release notes](https://github.com/caolan/async/releases)
- [Changelog](https://github.com/caolan/async/blob/v2.6.4/CHANGELOG.md)
- [Commits](https://github.com/caolan/async/compare/v2.6.2...v2.6.4)

---
updated-dependencies:
- dependency-name: async
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* docs: add info related to {orgs} and swagger ui

Signed-off-by: Wing-Kam Wong <wingkwong.code@gmail.com>

* Fix - Migration bugs (#1771)

* fix: handle formula parse error in formula migration

re #1760

Signed-off-by: Pranav C <pranavxc@gmail.com>

* fix: avoid project user insertion if corresponding project or user is missing

re #1760

Signed-off-by: Pranav C <pranavxc@gmail.com>

* fix: skip shared views if view_name/model_name is empty or missing

re #1760

Signed-off-by: Pranav C <pranavxc@gmail.com>

* fix: migration down statement correction

Signed-off-by: Pranav C <pranavxc@gmail.com>

* fix(migration): split alter table statement into multiple statements to support MSSQL

re #1764

Signed-off-by: Pranav C <pranavxc@gmail.com>

* refactor: add null check in upgrader

Signed-off-by: Pranav C <pranavxc@gmail.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Raju Udava <86527202+dstala@users.noreply.github.com>
Co-authored-by: աɨռɢӄաօռɢ <wingkwong.code@gmail.com>
Co-authored-by: navi <oof1lab@gmail.com>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
pull/1777/head 0.90.5
Pranav C 3 years ago committed by GitHub
parent
commit
412053039e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      .all-contributorsrc
  2. 1
      README.md
  3. 12
      packages/nc-cli/package-lock.json
  4. 5
      packages/nc-gui/components/project/functionTab/functionQuery.vue
  5. 5
      packages/nc-gui/components/project/spreadsheet/public/xcForm.vue
  6. 5
      packages/nc-gui/components/project/spreadsheet/public/xcTable.vue
  7. 4
      packages/nc-gui/components/project/sqlClient.vue
  8. 4
      packages/nc-gui/components/project/tableTabs/columns.vue
  9. 1224
      packages/nc-gui/helpers/sqlUi/MssqlUi.js
  10. 1262
      packages/nc-gui/helpers/sqlUi/MysqlUi.js
  11. 746
      packages/nc-gui/helpers/sqlUi/OracleUi.js
  12. 1851
      packages/nc-gui/helpers/sqlUi/PgUi.js
  13. 59
      packages/nc-gui/helpers/sqlUi/SqlUiFactory.js
  14. 1004
      packages/nc-gui/helpers/sqlUi/SqliteUi.js
  15. 6
      packages/nc-gui/helpers/sqlUi/index.js
  16. 50
      packages/nc-gui/lang/zh_CN.json
  17. 18
      packages/nc-migrator-archived/package-lock.json
  18. 6
      packages/nc-plugin/package-lock.json
  19. 6
      packages/noco-blog/package-lock.json
  20. 12
      packages/noco-docs-prev/package-lock.json
  21. 8
      packages/noco-docs/content/en/developer-resources/rest-apis.md
  22. 12
      packages/noco-docs/package-lock.json
  23. 6
      packages/noco-i18n/package-lock.json
  24. 6
      packages/nocodb-sdk/package-lock.json
  25. 6
      packages/nocodb/package-lock.json
  26. 2
      packages/nocodb/src/__tests__/restv2.test.ts
  27. 24
      packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSqlv2.ts
  28. 17
      packages/nocodb/src/lib/dataMapper/lib/sql/conditionV2.ts
  29. 2
      packages/nocodb/src/lib/dataMapper/lib/sql/formulav2/formulaQueryBuilderv2.ts
  30. 3
      packages/nocodb/src/lib/dataMapper/lib/sql/sortV2.ts
  31. 3
      packages/nocodb/src/lib/noco-models/Column.ts
  32. 3
      packages/nocodb/src/lib/noco-models/Filter.ts
  33. 3
      packages/nocodb/src/lib/noco-models/GalleryView.ts
  34. 3
      packages/nocodb/src/lib/noco-models/HookFilter.ts
  35. 10
      packages/nocodb/src/lib/noco-models/Model.ts
  36. 2
      packages/nocodb/src/lib/noco/common/BaseApiBuilder.ts
  37. 2
      packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts
  38. 4
      packages/nocodb/src/lib/noco/meta/api/columnApis.ts
  39. 3
      packages/nocodb/src/lib/noco/meta/api/metaDiffApis.ts
  40. 3
      packages/nocodb/src/lib/noco/meta/api/projectApis.ts
  41. 3
      packages/nocodb/src/lib/noco/meta/api/publicApis/publicMetaApis.ts
  42. 2
      packages/nocodb/src/lib/noco/meta/handlersv2/ncCreateLookup.ts
  43. 49
      packages/nocodb/src/lib/noco/migrationsv2/nc_011.ts
  44. 20
      packages/nocodb/src/lib/noco/migrationsv2/nc_012_alter_column_data_types.ts
  45. 66
      packages/nocodb/src/lib/noco/upgrader/jobs/ncProjectUpgraderV2_0090000.ts
  46. 2
      packages/nocodb/src/lib/sqlMgr/code/models/xc/BaseModelXcMeta.ts
  47. 1341
      packages/nocodb/src/lib/sqlUi/MssqlUi.ts
  48. 1282
      packages/nocodb/src/lib/sqlUi/MysqlUi.ts
  49. 947
      packages/nocodb/src/lib/sqlUi/OracleUi.ts
  50. 1970
      packages/nocodb/src/lib/sqlUi/PgUi.ts
  51. 70
      packages/nocodb/src/lib/sqlUi/SqlUiFactory.ts
  52. 1114
      packages/nocodb/src/lib/sqlUi/SqliteUi.ts
  53. 39
      packages/nocodb/src/lib/sqlUi/UITypes.ts
  54. 8
      packages/nocodb/src/lib/sqlUi/index.ts
  55. 6
      packages/nocodb/src/lib/templateParser/NcTemplateParser.ts
  56. 6
      scripts/cypress/fixtures/sqlite-sakila/regenFiles/package-lock.json

9
.all-contributorsrc

@ -711,6 +711,15 @@
"contributions": [ "contributions": [
"code" "code"
] ]
},
{
"login": "zprial",
"name": "zprial",
"avatar_url": "https://avatars.githubusercontent.com/u/33095380?v=4",
"profile": "https://github.com/zprial",
"contributions": [
"code"
]
} }
], ],
"contributorsPerLine": 7, "contributorsPerLine": 7,

1
README.md

@ -440,6 +440,7 @@ Our mission is to provide the most powerful no-code interface for databases whic
</tr> </tr>
<tr> <tr>
<td align="center"><a href="https://github.com/RobinFrcd"><img src="https://avatars.githubusercontent.com/u/29704178?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Robin Fourcade</b></sub></a><br /><a href="https://github.com/nocodb/nocodb/commits?author=RobinFrcd" title="Code">💻</a></td> <td align="center"><a href="https://github.com/RobinFrcd"><img src="https://avatars.githubusercontent.com/u/29704178?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Robin Fourcade</b></sub></a><br /><a href="https://github.com/nocodb/nocodb/commits?author=RobinFrcd" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/zprial"><img src="https://avatars.githubusercontent.com/u/33095380?v=4?s=100" width="100px;" alt=""/><br /><sub><b>zprial</b></sub></a><br /><a href="https://github.com/nocodb/nocodb/commits?author=zprial" title="Code">💻</a></td>
</tr> </tr>
</table> </table>

12
packages/nc-cli/package-lock.json generated

@ -1617,9 +1617,9 @@
} }
}, },
"node_modules/async": { "node_modules/async": {
"version": "2.6.3", "version": "2.6.4",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz",
"integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==",
"dependencies": { "dependencies": {
"lodash": "^4.17.14" "lodash": "^4.17.14"
} }
@ -17464,9 +17464,9 @@
"dev": true "dev": true
}, },
"async": { "async": {
"version": "2.6.3", "version": "2.6.4",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz",
"integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==",
"requires": { "requires": {
"lodash": "^4.17.14" "lodash": "^4.17.14"
} }

5
packages/nc-gui/components/project/functionTab/functionQuery.vue

@ -73,11 +73,10 @@
<script> <script>
import { mapGetters, mapActions } from 'vuex' import { mapGetters, mapActions } from 'vuex'
import { SqlUiFactory } from 'nocodb-sdk'
import MonacoEditor from '../../monaco/Monaco' import MonacoEditor from '../../monaco/Monaco'
import dlgLabelSubmitCancel from '../../utils/dlgLabelSubmitCancel' import dlgLabelSubmitCancel from '../../utils/dlgLabelSubmitCancel'
import { SqlUI } from '../../../helpers/sqlUi/SqlUiFactory'
export default { export default {
components: { MonacoEditor, dlgLabelSubmitCancel }, components: { MonacoEditor, dlgLabelSubmitCancel },
data() { data() {
@ -244,7 +243,7 @@ export default {
}, },
watch: {}, watch: {},
created() { created() {
this.sqlUi = SqlUI.create(this.nodes.dbConnection) this.sqlUi = SqlUiFactory.create(this.nodes.dbConnection)
}, },
mounted() { mounted() {
this.loadFunction() this.loadFunction()

5
packages/nc-gui/components/project/spreadsheet/public/xcForm.vue

@ -229,13 +229,12 @@
import { validationMixin } from 'vuelidate' import { validationMixin } from 'vuelidate'
import { required, minLength } from 'vuelidate/lib/validators' import { required, minLength } from 'vuelidate/lib/validators'
import { ErrorMessages, isVirtualCol, RelationTypes, UITypes } from 'nocodb-sdk' import { ErrorMessages, isVirtualCol, RelationTypes, UITypes, SqlUiFactory } from 'nocodb-sdk'
import form from '../mixins/form' import form from '../mixins/form'
import VirtualHeaderCell from '../components/virtualHeaderCell' import VirtualHeaderCell from '../components/virtualHeaderCell'
import HeaderCell from '../components/headerCell' import HeaderCell from '../components/headerCell'
import VirtualCell from '../components/virtualCell' import VirtualCell from '../components/virtualCell'
import EditableCell from '../components/editableCell' import EditableCell from '../components/editableCell'
import { SqlUI } from '../../../../helpers/sqlUi'
export default { export default {
name: 'XcForm', name: 'XcForm',
@ -273,7 +272,7 @@ export default {
sqlUiLoc() { sqlUiLoc() {
// todo: replace with correct client // todo: replace with correct client
return this.client && SqlUI.create({ client: this.client }) return this.client && SqlUiFactory.create({ client: this.client })
} }
}, },
watch: { watch: {

5
packages/nc-gui/components/project/spreadsheet/public/xcTable.vue

@ -125,14 +125,13 @@
<script> <script>
/* eslint-disable camelcase */ /* eslint-disable camelcase */
import { ErrorMessages } from 'nocodb-sdk' import { ErrorMessages, SqlUiFactory } from 'nocodb-sdk'
import spreadsheet from '../mixins/spreadsheet' import spreadsheet from '../mixins/spreadsheet'
import ApiFactory from '../apis/apiFactory' import ApiFactory from '../apis/apiFactory'
import FieldsMenu from '../components/fieldsMenu' import FieldsMenu from '../components/fieldsMenu'
import SortListMenu from '../components/sortListMenu' import SortListMenu from '../components/sortListMenu'
import ColumnFilterMenu from '../components/columnFilterMenu' import ColumnFilterMenu from '../components/columnFilterMenu'
import XcGridView from '../views/xcGridView' import XcGridView from '../views/xcGridView'
import { SqlUI } from '@/helpers/sqlUi'
import CsvExportImport from '~/components/project/spreadsheet/components/moreActions' import CsvExportImport from '~/components/project/spreadsheet/components/moreActions'
export default { export default {
@ -247,7 +246,7 @@ export default {
}, },
sqlUi() { sqlUi() {
// todo: replace with correct client // todo: replace with correct client
return SqlUI.create({ client: this.client }) return SqlUiFactory.create({ client: this.client })
}, },
queryParams() { queryParams() {
return { return {

4
packages/nc-gui/components/project/sqlClient.vue

@ -325,11 +325,11 @@ import { VueTreeList, Tree, TreeNode } from 'vue-tree-list'
import { Splitpanes, Pane } from 'splitpanes' import { Splitpanes, Pane } from 'splitpanes'
import sqlRightClickOptions from '../../helpers/sqlRightClickOptions' import sqlRightClickOptions from '../../helpers/sqlRightClickOptions'
import dlgLabelSubmitCancel from '../utils/dlgLabelSubmitCancel.vue' import dlgLabelSubmitCancel from '../utils/dlgLabelSubmitCancel.vue'
import { SqlUI } from '../../helpers/sqlUi/SqlUiFactory'
import Utils from '../../helpers/Utils' import Utils from '../../helpers/Utils'
import MonacoSqlEditor from '../monaco/MonacoSqlEditor' import MonacoSqlEditor from '../monaco/MonacoSqlEditor'
import {SqlUiFactory} from "nocodb-sdk";
export default { export default {
components: { components: {
@ -447,7 +447,7 @@ export default {
console.log('Failed to load previously opened query collections', e) console.log('Failed to load previously opened query collections', e)
} }
this.sqlUi = SqlUI.create(this.nodes.dbConnection) this.sqlUi = SqlUiFactory.create(this.nodes.dbConnection)
console.log('------------', this.nodes) console.log('------------', this.nodes)
this.editors = this.$store.state.sqlClient.editors.map(editor => ({ ...editor })) this.editors = this.$store.state.sqlClient.editors.map(editor => ({ ...editor }))
this.checkClipboardForQuery(this.$store.state.sqlClient.clipboardQuery) this.checkClipboardForQuery(this.$store.state.sqlClient.clipboardQuery)

4
packages/nc-gui/components/project/tableTabs/columns.vue

@ -709,10 +709,10 @@
<script> <script>
import { mapGetters, mapActions } from 'vuex' import { mapGetters, mapActions } from 'vuex'
import JSON5 from 'json5' import JSON5 from 'json5'
import { SqlUiFactory } from 'nocodb-sdk'
import addRelationDlg from '../dlgs/dlgAddRelation.vue' import addRelationDlg from '../dlgs/dlgAddRelation.vue'
import dlgLabelSubmitCancel from '../../utils/dlgLabelSubmitCancel.vue' import dlgLabelSubmitCancel from '../../utils/dlgLabelSubmitCancel.vue'
import { SqlUI } from '../../../helpers/sqlUi/SqlUiFactory'
import jsonToColumn from './columnActions/jsonToColumn' import jsonToColumn from './columnActions/jsonToColumn'
import uiTypes from '@/components/project/spreadsheet/helpers/uiTypes' import uiTypes from '@/components/project/spreadsheet/helpers/uiTypes'
@ -1271,7 +1271,7 @@ export default {
}, },
watch: {}, watch: {},
async created() { async created() {
this.sqlUi = SqlUI.create(this.nodes.dbConnection) this.sqlUi = SqlUiFactory.create(this.nodes.dbConnection)
try { try {
this.loading = true this.loading = true

1224
packages/nc-gui/helpers/sqlUi/MssqlUi.js

File diff suppressed because it is too large Load Diff

1262
packages/nc-gui/helpers/sqlUi/MysqlUi.js

File diff suppressed because it is too large Load Diff

746
packages/nc-gui/helpers/sqlUi/OracleUi.js

@ -1,746 +0,0 @@
export class OracleUi {
static getNewTableColumns() {
return [
{
column_name: 'id',
dt: 'integer',
dtx: 'integer',
ct: 'int(11)',
nrqd: false,
rqd: true,
ck: false,
pk: true,
un: false,
ai: false,
cdf: null,
clen: null,
np: null,
ns: null,
dtxp: '',
dtxs: '',
altered: 1,
uidt: 'ID',
uip: '',
uicn: ''
},
{
column_name: 'title',
dt: 'varchar',
dtx: 'specificType',
ct: 'varchar(45)',
nrqd: true,
rqd: false,
ck: false,
pk: false,
un: false,
ai: false,
cdf: null,
clen: 45,
np: null,
ns: null,
dtxp: '45',
dtxs: '',
altered: 1,
uidt: 'SingleLineText',
uip: '',
uicn: ''
}
]
}
static getNewColumn(suffix) {
return {
column_name: 'title' + suffix,
dt: 'integer',
dtx: 'specificType',
ct: 'integer(11)',
nrqd: true,
rqd: false,
ck: false,
pk: false,
un: false,
ai: false,
cdf: null,
clen: 45,
np: null,
ns: null,
// data_type_x_specific: ' ',
dtxp: '11',
dtxs: ' ',
altered: 1,
uidt: 'Number',
uip: '',
uicn: ''
}
}
static getDefaultLengthForDatatype(type) {
switch (type) {
default:
return ''
}
}
static getDefaultLengthIsDisabled(type) {
switch (type) {
case 'integer':
return true
case 'bfile':
case 'binary rowid':
case 'binary double':
case 'binary_float':
case 'blob':
case 'canoical':
case 'cfile':
case 'char':
case 'clob':
case 'content pointer':
case 'contigous array':
case 'date':
case 'decimal':
case 'double precision':
case 'float':
case 'interval day to second':
case 'interval year to month':
case 'lob pointer':
case 'long':
case 'long raw':
case 'named collection':
case 'named object':
case 'nchar':
case 'nclob':
case 'number':
case 'nvarchar2':
case 'octet':
case 'oid':
case 'pointer':
case 'raw':
case 'real':
case 'ref':
case 'ref cursor':
case 'rowid':
case 'signed binary integer':
case 'smallint':
case 'table':
case 'time':
case 'time with tz':
case 'timestamp':
case 'timestamp with local time zone':
case 'timestamp with local tz':
case 'timestamp with timezone':
case 'timestamp with tz':
case 'unsigned binary integer':
case 'urowid':
case 'varchar':
case 'varchar2':
case 'varray':
case 'varying array':
return false
}
}
static getDefaultValueForDatatype(type) {
switch (type) {
default:
return ''
}
}
static getDefaultScaleForDatatype(type) {
switch (type) {
case 'integer':
case 'bfile':
case 'binary rowid':
case 'binary double':
case 'binary_float':
case 'blob':
case 'canoical':
case 'cfile':
case 'char':
case 'clob':
case 'content pointer':
case 'contigous array':
case 'date':
case 'decimal':
case 'double precision':
case 'float':
case 'interval day to second':
case 'interval year to month':
case 'lob pointer':
case 'long':
case 'long raw':
case 'named collection':
case 'named object':
case 'nchar':
case 'nclob':
case 'number':
case 'nvarchar2':
case 'octet':
case 'oid':
case 'pointer':
case 'raw':
case 'real':
case 'ref':
case 'ref cursor':
case 'rowid':
case 'signed binary integer':
case 'smallint':
case 'table':
case 'time':
case 'time with tz':
case 'timestamp':
case 'timestamp with local time zone':
case 'timestamp with local tz':
case 'timestamp with timezone':
case 'timestamp with tz':
case 'unsigned binary integer':
case 'urowid':
case 'varchar':
case 'varchar2':
case 'varray':
case 'varying array':
return ' '
}
}
static colPropAIDisabled(col, columns) {
// console.log(col);
if (col.dt === 'int4' ||
col.dt === 'integer' ||
col.dt === 'bigint' ||
col.dt === 'smallint') {
for (let i = 0; i < columns.length; ++i) {
if (columns[i].column_name !== col.column_name && columns[i].ai) {
return true
}
}
return false
} else {
return true
}
}
static colPropUNDisabled(col) {
return true
}
static onCheckboxChangeAI(col) {
console.log(col)
if (col.dt === 'int' || col.dt === 'bigint' || col.dt === 'smallint' || col.dt === 'tinyint') {
col.altered = col.altered || 2
}
}
static showScale(columnObj) {
return false
}
static removeUnsigned(columns) {
for (let i = 0; i < columns.length; ++i) {
if (columns[i].altered === 1 && (!(columns[i].dt === 'int' ||
columns[i].dt === 'bigint' ||
columns[i].dt === 'tinyint' ||
columns[i].dt === 'smallint' ||
columns[i].dt === 'mediumint'))) {
columns[i].un = false
console.log('>> resetting unsigned value', columns[i].column_name)
}
console.log(columns[i].column_name)
}
}
static columnEditable(colObj) {
return colObj.table_name !== '_evolutions' || colObj.table_name !== 'nc_evolutions'
}
static extractFunctionName(query) {
const reg = /^\s*CREATE\s+(?:OR\s+REPLACE\s*)?\s*FUNCTION\s+(?:[\w\d_]+\.)?([\w_\d]+)/i
const match = query.match(reg)
return match && match[1]
}
static extractProcedureName(query) {
const reg = /^\s*CREATE\s+(?:OR\s+REPLACE\s*)?\s*PROCEDURE\s+(?:[\w\d_]+\.)?([\w_\d]+)/i
const match = query.match(reg)
return match && match[1]
}
static splitQueries(query) {
/***
* we are splitting based on semicolon
* there are mechanism to escape semicolon within single/double quotes(string)
*/
return query.match(/\b("[^"]*;[^"]*"|'[^']*;[^']*'|[^;])*;/g)
}
static onCheckboxChangeAU(col) {
console.log(col)
col.altered = col.altered || 2
}
/**
* if sql statement is SELECT - it limits to a number
* @param args
* @returns {string|*}
*/
sanitiseQuery(args) {
let q = args.query.trim().split(';')
if (q[0].startsWith('Select')) {
q = q[0] + ` LIMIT 0,${args.limit ? args.limit : 100};`
} else if (q[0].startsWith('select')) {
q = q[0] + ` LIMIT 0,${args.limit ? args.limit : 100};`
} else if (q[0].startsWith('SELECT')) {
q = q[0] + ` LIMIT 0,${args.limit ? args.limit : 100};`
} else {
return args.query
}
return q
}
getColumnsFromJson(json, tn) {
const columns = []
try {
if (typeof json === 'object' && !Array.isArray(json)) {
const keys = Object.keys(json)
for (let i = 0; i < keys.length; ++i) {
switch (typeof json[keys[i]]) {
case 'number':
if (Number.isInteger(json[keys[i]])) {
columns.push({
dp: null,
tn,
column_name: keys[i],
cno: keys[i],
dt: 'int',
np: 10,
ns: 0,
clen: null,
cop: 1,
pk: false,
nrqd: false,
rqd: false,
un: false,
ct: 'int(11) unsigned',
ai: false,
unique: false,
cdf: null,
cc: '',
csn: null,
dtx: 'specificType',
dtxp: '11',
dtxs: 0,
altered: 1
})
} else {
columns.push({
dp: null,
tn,
column_name: keys[i],
cno: keys[i],
dt: 'float',
np: 10,
ns: 2,
clen: null,
cop: 1,
pk: false,
nrqd: false,
rqd: false,
un: false,
ct: 'int(11) unsigned',
ai: false,
unique: false,
cdf: null,
cc: '',
csn: null,
dtx: 'specificType',
dtxp: '11',
dtxs: 2,
altered: 1
})
}
break
case 'string':
if (json[keys[i]].length <= 255) {
columns.push({
dp: null,
tn,
column_name: keys[i],
cno: keys[i],
dt: 'varchar',
np: 45,
ns: 0,
clen: null,
cop: 1,
pk: false,
nrqd: false,
rqd: false,
un: false,
ct: 'int(11) unsigned',
ai: false,
unique: false,
cdf: null,
cc: '',
csn: null,
dtx: 'specificType',
dtxp: '45',
dtxs: 0,
altered: 1
})
} else {
columns.push({
dp: null,
tn,
column_name: keys[i],
cno: keys[i],
dt: 'text',
np: null,
ns: 0,
clen: null,
cop: 1,
pk: false,
nrqd: false,
rqd: false,
un: false,
ct: 'int(11) unsigned',
ai: false,
unique: false,
cdf: null,
cc: '',
csn: null,
dtx: 'specificType',
dtxp: null,
dtxs: 0,
altered: 1
})
}
break
case 'boolean':
columns.push({
dp: null,
tn,
column_name: keys[i],
cno: keys[i],
dt: 'boolean',
np: 3,
ns: 0,
clen: null,
cop: 1,
pk: false,
nrqd: false,
rqd: false,
un: false,
ct: 'int(11) unsigned',
ai: false,
unique: false,
cdf: null,
cc: '',
csn: null,
dtx: 'specificType',
dtxp: '1',
dtxs: 0,
altered: 1
})
break
case 'object':
columns.push({
dp: null,
tn,
column_name: keys[i],
cno: keys[i],
dt: 'json',
np: 3,
ns: 0,
clen: null,
cop: 1,
pk: false,
nrqd: false,
rqd: false,
un: false,
ct: 'int(11) unsigned',
ai: false,
unique: false,
cdf: null,
cc: '',
csn: null,
dtx: 'specificType',
dtxp: null,
dtxs: 0,
altered: 1
})
break
default:
break
}
}
}
} catch (e) {
console.log('Error in getColumnsFromJson', e)
}
return columns
}
static colPropAuDisabled(col) {
return true
}
static getAbstractType(col) {
switch ((col.dt || col.dt).toLowerCase()) {
case 'integer':
return 'integer'
case 'bfile':
case 'binary rowid':
case 'binary double':
case 'binary_float':
return 'string'
case 'blob':
return 'blob'
case 'canoical':
case 'cfile':
case 'char':
case 'clob':
case 'content pointer':
case 'contigous array':
return 'string'
case 'date':
return 'date'
case 'decimal':
case 'double precision':
case 'float':
return 'float'
case 'interval day to second':
case 'interval year to month':
return 'string'
case 'lob pointer':
return 'string'
case 'long':
return 'integer'
case 'long raw':
return 'string'
case 'named collection':
case 'named object':
case 'nchar':
case 'nclob':
return 'string'
case 'nvarchar2':
case 'octet':
case 'oid':
case 'pointer':
case 'raw':
return 'string'
case 'real':
case 'number':
return 'float'
case 'ref':
case 'ref cursor':
case 'rowid':
case 'signed binary integer':
return 'string'
case 'smallint':
return 'integer'
case 'table':
return 'string'
case 'time':
case 'time with tz':
return 'time'
case 'timestamp':
case 'timestamp with local time zone':
case 'timestamp with local tz':
case 'timestamp with timezone':
case 'timestamp with tz':
return 'datetime'
case 'unsigned binary integer':
case 'urowid':
case 'varchar':
case 'varchar2':
return 'string'
case 'varray':
case 'varying array':
return 'string'
}
}
static getUIType(col) {
switch (this.getAbstractType(col)) {
case 'integer':
return 'Number'
case 'boolean':
return 'Checkbox'
case 'float':
return 'Decimal'
case 'date':
return 'Date'
case 'datetime':
return 'CreateTime'
case 'time':
return 'Time'
case 'year':
return 'Year'
case 'string':
return 'SingleLineText'
case 'text':
return 'LongText'
case 'blob':
return 'Attachment'
case 'enum':
return 'SingleSelect'
case 'set':
return 'MultiSelect'
case 'json':
return 'LongText'
}
}
static getDataTypeForUiType(col) {
const colProp = {}
switch (col.uidt) {
case 'ID':
colProp.dt = 'integer'
colProp.pk = true
colProp.un = true
colProp.ai = true
colProp.rqd = true
break
case 'ForeignKey':
colProp.dt = 'varchar'
break
case 'SingleLineText':
colProp.dt = 'varchar'
break
case 'LongText':
colProp.dt = 'clob'
break
case 'Attachment':
colProp.dt = 'clob'
break
case 'Checkbox':
colProp.dt = 'tinyint'
colProp.dtxp = 1
break
case 'MultiSelect':
colProp.dt = 'varchar2'
break
case 'SingleSelect':
colProp.dt = 'varchar2'
break
case 'Collaborator':
colProp.dt = 'varchar'
break
case 'Date':
colProp.dt = 'varchar'
break
case 'Year':
colProp.dt = 'year'
break
case 'Time':
colProp.dt = 'time'
break
case 'PhoneNumber':
colProp.dt = 'varchar'
colProp.validate = { func: ['isMobilePhone'], args: [''], msg: ['Validation failed : Invalid Mobile Format'] }
break
case 'Email':
colProp.dt = 'varchar'
colProp.validate = { func: ['isEmail'], args: [''], msg: ['Validation failed : Invalid Email Format'] }
break
case 'URL':
colProp.dt = 'varchar'
colProp.validate = { func: ['isURL'], args: [''], msg: ['Validation failed : Invalid URL Format'] }
break
case 'Number':
colProp.dt = 'integer'
break
case 'Decimal':
colProp.dt = 'decimal'
break
case 'Currency':
colProp.dt = 'decimal'
colProp.validate = { func: ['isCurrency'], args: [''], msg: ['Validation failed : Invalid Currency Format'] }
break
case 'Percent':
colProp.dt = 'double'
break
case 'Duration':
colProp.dt = 'integer'
break
case 'Rating':
colProp.dt = 'float'
break
case 'Formula':
colProp.dt = 'varchar'
break
case 'Rollup':
colProp.dt = 'varchar'
break
case 'Count':
colProp.dt = 'integer'
break
case 'Lookup':
colProp.dt = 'varchar'
break
case 'DateTime':
colProp.dt = 'timestamp'
break
case 'CreateTime':
colProp.dt = 'timestamp'
break
case 'LastModifiedTime':
colProp.dt = 'timestamp'
break
case 'AutoNumber':
colProp.dt = 'integer'
break
case 'Barcode':
colProp.dt = 'varchar'
break
case 'Button':
colProp.dt = 'varchar'
break
default:
colProp.dt = 'varchar'
break
}
return colProp
}
static getUnsupportedFnList() {
return []
}
}
// module.exports = PgUiHelp;
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

1851
packages/nc-gui/helpers/sqlUi/PgUi.js

File diff suppressed because it is too large Load Diff

59
packages/nc-gui/helpers/sqlUi/SqlUiFactory.js

@ -1,59 +0,0 @@
import { MysqlUi } from './MysqlUi'
import { PgUi } from './PgUi'
import { MssqlUi } from './MssqlUi'
import { OracleUi } from './OracleUi'
import { SqliteUi } from './SqliteUi'
// import {YugabyteUi} from "./YugabyteUi";
// import {TidbUi} from "./TidbUi";
// import {VitessUi} from "./VitessUi";
export class SqlUI {
static create(connectionConfig) {
if (connectionConfig.client === 'mysql' || connectionConfig.client === 'mysql2') {
// if (connectionConfig.meta.dbtype === "tidb")
// return Tidb;
// if (connectionConfig.meta.dbtype === "vitess")
// return Vitess;
console.log('- - - -In Mysql UI')
return MysqlUi
}
if (connectionConfig.client === 'sqlite3') { return SqliteUi }
if (connectionConfig.client === 'mssql') { return MssqlUi }
if (connectionConfig.client === 'oracledb') { return OracleUi }
if (connectionConfig.client === 'pg') {
// if (connectionConfig.meta.dbtype === "yugabyte")
// return Yugabyte;
return PgUi
}
throw new Error('Database not supported')
}
}
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

1004
packages/nc-gui/helpers/sqlUi/SqliteUi.js

File diff suppressed because it is too large Load Diff

6
packages/nc-gui/helpers/sqlUi/index.js

@ -1,6 +0,0 @@
export * from './MysqlUi'
export * from './PgUi'
export * from './MssqlUi'
export * from './OracleUi'
export * from './SqliteUi'
export * from './SqlUiFactory'

50
packages/nc-gui/lang/zh_CN.json

@ -1,6 +1,6 @@
{ {
"general": { "general": {
"home": "", "home": "首页",
"load": "加载", "load": "加载",
"open": "打开", "open": "打开",
"close": "关闭", "close": "关闭",
@ -26,7 +26,7 @@
"show": "展示", "show": "展示",
"hide": "隐藏", "hide": "隐藏",
"showAll": "显示所有", "showAll": "显示所有",
"hideAll": "全部藏起来", "hideAll": "隐藏全部",
"showMore": "显示更多", "showMore": "显示更多",
"showOptions": "显示选项", "showOptions": "显示选项",
"hideOptions": "隐藏选项", "hideOptions": "隐藏选项",
@ -48,7 +48,7 @@
"more": "更多的", "more": "更多的",
"less": "较少的", "less": "较少的",
"event": "事件", "event": "事件",
"condition": "健康)状况", "condition": "条件",
"after": "后", "after": "后",
"before": "前", "before": "前",
"search": "搜索", "search": "搜索",
@ -59,11 +59,11 @@
"objects": { "objects": {
"project": "项目", "project": "项目",
"projects": "项目", "projects": "项目",
"table": "桌子", "table": "表格",
"tables": "桌子", "tables": "表格",
"field": "场地", "field": "字段",
"fields": "领域", "fields": "字段",
"column": "柱子", "column": "",
"columns": "列", "columns": "列",
"page": "页", "page": "页",
"pages": "页面", "pages": "页面",
@ -71,7 +71,7 @@
"records": "记录", "records": "记录",
"webhook": "Webhook.", "webhook": "Webhook.",
"webhooks": "Webhooks.", "webhooks": "Webhooks.",
"view": "看法", "view": "视图",
"views": "视图", "views": "视图",
"viewType": { "viewType": {
"grid": "表格", "grid": "表格",
@ -94,10 +94,10 @@
}, },
"datatype": { "datatype": {
"ID": "ID", "ID": "ID",
"ForeignKey": "外钥匙", "ForeignKey": "外",
"SingleLineText": "单行文本", "SingleLineText": "单行文本",
"LongText": "长篇文章", "LongText": "长文本",
"Attachment": "依恋", "Attachment": "附件",
"Checkbox": "复选框", "Checkbox": "复选框",
"MultiSelect": "多选", "MultiSelect": "多选",
"SingleSelect": "单个选择", "SingleSelect": "单个选择",
@ -116,9 +116,9 @@
"Rating": "评分", "Rating": "评分",
"Formula": "公式", "Formula": "公式",
"Rollup": "卷起", "Rollup": "卷起",
"Count": "数", "Count": "数",
"Lookup": "抬头", "Lookup": "查找",
"DateTime": "约会时间", "DateTime": "日期时间",
"CreateTime": "创建时间", "CreateTime": "创建时间",
"LastModifiedTime": "最后修改时间", "LastModifiedTime": "最后修改时间",
"AutoNumber": "自动编号", "AutoNumber": "自动编号",
@ -191,19 +191,19 @@
"password": "密码", "password": "密码",
"action": "行动", "action": "行动",
"actions": "行动", "actions": "行动",
"operation": "手术", "operation": "操作",
"operationType": "操作类型", "operationType": "操作类型",
"operationSubType": "操作子类型", "operationSubType": "操作子类型",
"description": "描述", "description": "描述",
"authentication": "验证", "authentication": "验证",
"token": "令牌", "token": "令牌",
"where": "在哪里", "where": "where",
"cache": "缓存", "cache": "缓存",
"chat": "聊天", "chat": "聊天",
"email": "电子邮件", "email": "电子邮件",
"storage": "贮存", "storage": "贮存",
"uiAcl": "UI-ACL", "uiAcl": "UI-ACL",
"models": "模", "models": "模",
"syncState": "同步状态", "syncState": "同步状态",
"created": "创造了", "created": "创造了",
"sqlOutput": "SQL输出", "sqlOutput": "SQL输出",
@ -231,14 +231,14 @@
}, },
"docReference": "文件参考文献", "docReference": "文件参考文献",
"selectUserRole": "选择用户角色", "selectUserRole": "选择用户角色",
"childTable": "儿童表", "childTable": "表",
"childColumn": "儿童专栏", "childColumn": "子列",
"onUpdate": "更新", "onUpdate": "更新",
"onDelete": "删除" "onDelete": "删除"
}, },
"activity": { "activity": {
"createProject": "创建项目", "createProject": "创建项目",
"importProject": "进口项目", "importProject": "导入项目",
"searchProject": "搜索项目", "searchProject": "搜索项目",
"editProject": "编辑项目", "editProject": "编辑项目",
"stopProject": "停止项目", "stopProject": "停止项目",
@ -265,7 +265,7 @@
"projInfo": "复制项目信息", "projInfo": "复制项目信息",
"themes": "主题" "themes": "主题"
}, },
"sort": "种类", "sort": "排序",
"addSort": "添加排序选项", "addSort": "添加排序选项",
"filter": "筛选", "filter": "筛选",
"addFilter": "添加过滤器", "addFilter": "添加过滤器",
@ -338,7 +338,7 @@
"testDbConn": "测试数据库链接", "testDbConn": "测试数据库链接",
"removeDbFromEnv": "从环境中删除数据库", "removeDbFromEnv": "从环境中删除数据库",
"editConnJson": "编辑链接JSON", "editConnJson": "编辑链接JSON",
"sponsorUs": "赞助美国", "sponsorUs": "赞助我们",
"sendEmail": "发送邮件" "sendEmail": "发送邮件"
}, },
"tooltip": { "tooltip": {
@ -422,7 +422,7 @@
"showBlankForm": "5秒后显示空白表格", "showBlankForm": "5秒后显示空白表格",
"emailForm": "发电子邮件给我", "emailForm": "发电子邮件给我",
"showSysFields": "显示系统字段", "showSysFields": "显示系统字段",
"filterAutoApply": "自动申请", "filterAutoApply": "自动应用",
"showMessage": "显示此消息", "showMessage": "显示此消息",
"viewNotShared": "当前视图不共享!", "viewNotShared": "当前视图不共享!",
"showAllViews": "显示此表的所有共享视图", "showAllViews": "显示此表的所有共享视图",

18
packages/nc-migrator-archived/package-lock.json generated

@ -272,6 +272,15 @@
"integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==",
"dev": true "dev": true
}, },
"async": {
"version": "2.6.4",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz",
"integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==",
"dev": true,
"requires": {
"lodash": "^4.17.14"
}
},
"atob": { "atob": {
"version": "2.1.2", "version": "2.1.2",
"resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz",
@ -2844,15 +2853,6 @@
"integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=",
"dev": true "dev": true
}, },
"async": {
"version": "2.6.2",
"resolved": false,
"integrity": "sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg==",
"dev": true,
"requires": {
"lodash": "^4.17.11"
}
},
"balanced-match": { "balanced-match": {
"version": "1.0.0", "version": "1.0.0",
"resolved": false, "resolved": false,

6
packages/nc-plugin/package-lock.json generated

@ -1176,9 +1176,9 @@
"dev": true "dev": true
}, },
"async": { "async": {
"version": "2.6.3", "version": "2.6.4",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz",
"integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==",
"dev": true, "dev": true,
"requires": { "requires": {
"lodash": "^4.17.14" "lodash": "^4.17.14"

6
packages/noco-blog/package-lock.json generated

@ -3275,9 +3275,9 @@
"integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=" "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c="
}, },
"async": { "async": {
"version": "2.6.3", "version": "2.6.4",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz",
"integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==",
"requires": { "requires": {
"lodash": "^4.17.14" "lodash": "^4.17.14"
} }

12
packages/noco-docs-prev/package-lock.json generated

@ -4103,9 +4103,9 @@
} }
}, },
"node_modules/async": { "node_modules/async": {
"version": "2.6.3", "version": "2.6.4",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz",
"integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==",
"dependencies": { "dependencies": {
"lodash": "^4.17.14" "lodash": "^4.17.14"
} }
@ -20089,9 +20089,9 @@
"integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=" "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c="
}, },
"async": { "async": {
"version": "2.6.3", "version": "2.6.4",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz",
"integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==",
"requires": { "requires": {
"lodash": "^4.17.14" "lodash": "^4.17.14"
} }

8
packages/noco-docs/content/en/developer-resources/rest-apis.md

@ -11,6 +11,14 @@ Once you've created the schemas, you can manipulate the data or invoke actions u
Here's the overview of all APIs. For the details, please check out <a href="https://all-apis.nocodb.com/" target="_blank">NocoDB API Documentation</a>. Here's the overview of all APIs. For the details, please check out <a href="https://all-apis.nocodb.com/" target="_blank">NocoDB API Documentation</a>.
<alert type="danger">
Swagger UI has been removed from GUI and may be supported in the future release.
</alert>
<alert type="success">
Currently, the default value for {orgs} is <b>noco</b>. Users will be able to change it in the future release.
</alert>
### Auth APIs ### Auth APIs
| Category | Method | Tag | Function Name | Path | | Category | Method | Tag | Function Name | Path |

12
packages/noco-docs/package-lock.json generated

@ -4103,9 +4103,9 @@
} }
}, },
"node_modules/async": { "node_modules/async": {
"version": "2.6.3", "version": "2.6.4",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz",
"integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==",
"dependencies": { "dependencies": {
"lodash": "^4.17.14" "lodash": "^4.17.14"
} }
@ -20089,9 +20089,9 @@
"integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=" "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c="
}, },
"async": { "async": {
"version": "2.6.3", "version": "2.6.4",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz",
"integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==",
"requires": { "requires": {
"lodash": "^4.17.14" "lodash": "^4.17.14"
} }

6
packages/noco-i18n/package-lock.json generated

@ -2416,9 +2416,9 @@
"dev": true "dev": true
}, },
"async": { "async": {
"version": "2.6.3", "version": "2.6.4",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz",
"integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==",
"dev": true, "dev": true,
"requires": { "requires": {
"lodash": "^4.17.14" "lodash": "^4.17.14"

6
packages/nocodb-sdk/package-lock.json generated

@ -1176,9 +1176,9 @@
"dev": true "dev": true
}, },
"async": { "async": {
"version": "2.6.3", "version": "2.6.4",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz",
"integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==",
"dev": true, "dev": true,
"requires": { "requires": {
"lodash": "^4.17.14" "lodash": "^4.17.14"

6
packages/nocodb/package-lock.json generated

@ -11606,9 +11606,9 @@
} }
}, },
"minimist": { "minimist": {
"version": "1.2.5", "version": "1.2.6",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q=="
}, },
"minimist-options": { "minimist-options": {
"version": "3.0.2", "version": "3.0.2",

2
packages/nocodb/src/__tests__/restv2.test.ts

@ -5,7 +5,7 @@ import request from 'supertest';
import { Noco } from '../lib'; import { Noco } from '../lib';
import NcConfigFactory from '../lib/utils/NcConfigFactory'; import NcConfigFactory from '../lib/utils/NcConfigFactory';
import UITypes from '../lib/sqlUi/UITypes'; import { UITypes } from 'nocodb-sdk';
const knex = require('knex'); const knex = require('knex');

24
packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSqlv2.ts

@ -4,7 +4,6 @@ import _ from 'lodash';
import Model from '../../../noco-models/Model'; import Model from '../../../noco-models/Model';
import { XKnex } from '../..'; import { XKnex } from '../..';
import LinkToAnotherRecordColumn from '../../../noco-models/LinkToAnotherRecordColumn'; import LinkToAnotherRecordColumn from '../../../noco-models/LinkToAnotherRecordColumn';
import UITypes from '../../../sqlUi/UITypes';
import RollupColumn from '../../../noco-models/RollupColumn'; import RollupColumn from '../../../noco-models/RollupColumn';
import LookupColumn from '../../../noco-models/LookupColumn'; import LookupColumn from '../../../noco-models/LookupColumn';
import DataLoader from 'dataloader'; import DataLoader from 'dataloader';
@ -25,6 +24,7 @@ import {
isSystemColumn, isSystemColumn,
RelationTypes, RelationTypes,
SortType, SortType,
UITypes,
ViewTypes ViewTypes
} from 'nocodb-sdk'; } from 'nocodb-sdk';
import formSubmissionEmailTemplate from '../../../noco/common/formSubmissionEmailTemplate'; import formSubmissionEmailTemplate from '../../../noco/common/formSubmissionEmailTemplate';
@ -1864,10 +1864,13 @@ class BaseModelSqlv2 {
{ {
await this.dbDriver(childTable.table_name) await this.dbDriver(childTable.table_name)
.update({ .update({
[childColumn.column_name]: this.dbDriver(parentTable.table_name) [childColumn.column_name]: this.dbDriver.from(
.select(parentColumn.column_name) this.dbDriver(parentTable.table_name)
.where(_wherePk(parentTable.primaryKeys, rowId)) .select(parentColumn.column_name)
.first() .where(_wherePk(parentTable.primaryKeys, rowId))
.first()
.as('___cn_alias')
)
}) })
.where(_wherePk(childTable.primaryKeys, childId)); .where(_wherePk(childTable.primaryKeys, childId));
} }
@ -1876,10 +1879,13 @@ class BaseModelSqlv2 {
{ {
await this.dbDriver(childTable.table_name) await this.dbDriver(childTable.table_name)
.update({ .update({
[childColumn.column_name]: this.dbDriver(parentTable.table_name) [childColumn.column_name]: this.dbDriver.from(
.select(parentColumn.column_name) this.dbDriver(parentTable.table_name)
.where(_wherePk(parentTable.primaryKeys, childId)) .select(parentColumn.column_name)
.first() .where(_wherePk(parentTable.primaryKeys, childId))
.first()
.as('___cn_alias')
)
}) })
.where(_wherePk(childTable.primaryKeys, rowId)); .where(_wherePk(childTable.primaryKeys, rowId));
} }

17
packages/nocodb/src/lib/dataMapper/lib/sql/conditionV2.ts

@ -1,5 +1,4 @@
import Filter from '../../../noco-models/Filter'; import Filter from '../../../noco-models/Filter';
import UITypes from '../../../sqlUi/UITypes';
import LinkToAnotherRecordColumn from '../../../noco-models/LinkToAnotherRecordColumn'; import LinkToAnotherRecordColumn from '../../../noco-models/LinkToAnotherRecordColumn';
import { QueryBuilder } from 'knex'; import { QueryBuilder } from 'knex';
import { XKnex } from '../..'; import { XKnex } from '../..';
@ -9,7 +8,7 @@ import genRollupSelectv2 from './genRollupSelectv2';
import RollupColumn from '../../../noco-models/RollupColumn'; import RollupColumn from '../../../noco-models/RollupColumn';
import formulaQueryBuilderv2 from './formulav2/formulaQueryBuilderv2'; import formulaQueryBuilderv2 from './formulav2/formulaQueryBuilderv2';
import FormulaColumn from '../../../noco-models/FormulaColumn'; import FormulaColumn from '../../../noco-models/FormulaColumn';
import { RelationTypes } from 'nocodb-sdk'; import { RelationTypes, UITypes } from 'nocodb-sdk';
// import LookupColumn from '../../../noco-models/LookupColumn'; // import LookupColumn from '../../../noco-models/LookupColumn';
export default async function conditionV2( export default async function conditionV2(
@ -111,7 +110,7 @@ const parseConditionV2 = async (
}; };
} else if (colOptions.type === RelationTypes.BELONGS_TO) { } else if (colOptions.type === RelationTypes.BELONGS_TO) {
const selectQb = knex(parentModel.table_name).select( const selectQb = knex(parentModel.table_name).select(
childColumn.column_name parentColumn.column_name
); );
( (
await parseConditionV2( await parseConditionV2(
@ -324,7 +323,7 @@ async function generateLookupCondition(
const parentModel = await parentColumn.getModel(); const parentModel = await parentColumn.getModel();
await parentModel.getColumns(); await parentModel.getColumns();
if (relationColumnOptions.type === 'hm') { if (relationColumnOptions.type === RelationTypes.HAS_MANY) {
qb = knex(`${childModel.table_name} as ${alias}`); qb = knex(`${childModel.table_name} as ${alias}`);
qb.select(`${alias}.${childColumn.column_name}`); qb.select(`${alias}.${childColumn.column_name}`);
@ -348,7 +347,7 @@ async function generateLookupCondition(
qbP.whereNotIn(parentColumn.column_name, qb); qbP.whereNotIn(parentColumn.column_name, qb);
else qbP.whereIn(parentColumn.column_name, qb); else qbP.whereIn(parentColumn.column_name, qb);
}; };
} else if (relationColumnOptions.type === 'bt') { } else if (relationColumnOptions.type === RelationTypes.BELONGS_TO) {
qb = knex(`${parentModel.table_name} as ${alias}`); qb = knex(`${parentModel.table_name} as ${alias}`);
qb.select(`${alias}.${childColumn.column_name}`); qb.select(`${alias}.${childColumn.column_name}`);
@ -440,7 +439,7 @@ async function nestedConditionJoin(
await parentModel.getColumns(); await parentModel.getColumns();
{ {
switch (relationColOptions.type) { switch (relationColOptions.type) {
case 'hm': case RelationTypes.HAS_MANY:
{ {
qb.join( qb.join(
`${childModel.table_name} as ${relAlias}`, `${childModel.table_name} as ${relAlias}`,
@ -449,7 +448,7 @@ async function nestedConditionJoin(
); );
} }
break; break;
case 'bt': case RelationTypes.BELONGS_TO:
{ {
qb.join( qb.join(
`${parentModel.table_name} as ${relAlias}`, `${parentModel.table_name} as ${relAlias}`,
@ -493,7 +492,7 @@ async function nestedConditionJoin(
); );
} else { } else {
switch (relationColOptions.type) { switch (relationColOptions.type) {
case 'hm': case RelationTypes.HAS_MANY:
{ {
( (
await parseConditionV2( await parseConditionV2(
@ -509,7 +508,7 @@ async function nestedConditionJoin(
)(qb); )(qb);
} }
break; break;
case 'bt': case RelationTypes.BELONGS_TO:
{ {
( (
await parseConditionV2( await parseConditionV2(

2
packages/nocodb/src/lib/dataMapper/lib/sql/formulav2/formulaQueryBuilderv2.ts

@ -1,13 +1,13 @@
import jsep from 'jsep'; import jsep from 'jsep';
import mapFunctionName from '../mapFunctionName'; import mapFunctionName from '../mapFunctionName';
import Model from '../../../../noco-models/Model'; import Model from '../../../../noco-models/Model';
import UITypes from '../../../../sqlUi/UITypes';
import genRollupSelectv2 from '../genRollupSelectv2'; import genRollupSelectv2 from '../genRollupSelectv2';
import RollupColumn from '../../../../noco-models/RollupColumn'; import RollupColumn from '../../../../noco-models/RollupColumn';
import FormulaColumn from '../../../../noco-models/FormulaColumn'; import FormulaColumn from '../../../../noco-models/FormulaColumn';
import { XKnex } from '../../..'; import { XKnex } from '../../..';
import LinkToAnotherRecordColumn from '../../../../noco-models/LinkToAnotherRecordColumn'; import LinkToAnotherRecordColumn from '../../../../noco-models/LinkToAnotherRecordColumn';
import LookupColumn from '../../../../noco-models/LookupColumn'; import LookupColumn from '../../../../noco-models/LookupColumn';
import { UITypes } from 'nocodb-sdk';
// todo: switch function based on database // todo: switch function based on database

3
packages/nocodb/src/lib/dataMapper/lib/sql/sortV2.ts

@ -1,14 +1,13 @@
import { QueryBuilder } from 'knex'; import { QueryBuilder } from 'knex';
import { XKnex } from '../..'; import { XKnex } from '../..';
import Sort from '../../../noco-models/Sort'; import Sort from '../../../noco-models/Sort';
import UITypes from '../../../sqlUi/UITypes';
import LinkToAnotherRecordColumn from '../../../noco-models/LinkToAnotherRecordColumn'; import LinkToAnotherRecordColumn from '../../../noco-models/LinkToAnotherRecordColumn';
import genRollupSelectv2 from './genRollupSelectv2'; import genRollupSelectv2 from './genRollupSelectv2';
import RollupColumn from '../../../noco-models/RollupColumn'; import RollupColumn from '../../../noco-models/RollupColumn';
import LookupColumn from '../../../noco-models/LookupColumn'; import LookupColumn from '../../../noco-models/LookupColumn';
import formulaQueryBuilderv2 from './formulav2/formulaQueryBuilderv2'; import formulaQueryBuilderv2 from './formulav2/formulaQueryBuilderv2';
import FormulaColumn from '../../../noco-models/FormulaColumn'; import FormulaColumn from '../../../noco-models/FormulaColumn';
import { RelationTypes } from 'nocodb-sdk'; import { RelationTypes, UITypes } from 'nocodb-sdk';
export default async function sortV2( export default async function sortV2(
sortList: Sort[], sortList: Sort[],

3
packages/nocodb/src/lib/noco-models/Column.ts

@ -1,4 +1,3 @@
import UITypes from '../sqlUi/UITypes';
import FormulaColumn from './FormulaColumn'; import FormulaColumn from './FormulaColumn';
import LinkToAnotherRecordColumn from './LinkToAnotherRecordColumn'; import LinkToAnotherRecordColumn from './LinkToAnotherRecordColumn';
import LookupColumn from './LookupColumn'; import LookupColumn from './LookupColumn';
@ -7,7 +6,7 @@ import SingleSelectColumn from './SingleSelectColumn';
import MultiSelectColumn from './MultiSelectColumn'; import MultiSelectColumn from './MultiSelectColumn';
import Model from './Model'; import Model from './Model';
import NocoCache from '../noco-cache/NocoCache'; import NocoCache from '../noco-cache/NocoCache';
import { ColumnType } from 'nocodb-sdk'; import { ColumnType, UITypes } from 'nocodb-sdk';
import { import {
CacheDelDirection, CacheDelDirection,
CacheGetType, CacheGetType,

3
packages/nocodb/src/lib/noco-models/Filter.ts

@ -1,7 +1,6 @@
import Noco from '../../lib/noco/Noco'; import Noco from '../../lib/noco/Noco';
import Model from './Model'; import Model from './Model';
import Column from './Column'; import Column from './Column';
import UITypes from '../sqlUi/UITypes';
import { import {
CacheDelDirection, CacheDelDirection,
CacheGetType, CacheGetType,
@ -9,7 +8,7 @@ import {
MetaTable MetaTable
} from '../utils/globals'; } from '../utils/globals';
import View from './View'; import View from './View';
import { FilterType } from 'nocodb-sdk'; import { FilterType, UITypes } from 'nocodb-sdk';
import NocoCache from '../noco-cache/NocoCache'; import NocoCache from '../noco-cache/NocoCache';
export default class Filter { export default class Filter {

3
packages/nocodb/src/lib/noco-models/GalleryView.ts

@ -1,8 +1,7 @@
import Noco from '../noco/Noco'; import Noco from '../noco/Noco';
import { CacheGetType, CacheScope, MetaTable } from '../utils/globals'; import { CacheGetType, CacheScope, MetaTable } from '../utils/globals';
import { GalleryColumnType, GalleryType } from 'nocodb-sdk'; import { GalleryColumnType, GalleryType, UITypes } from 'nocodb-sdk';
import View from './View'; import View from './View';
import UITypes from '../sqlUi/UITypes';
import NocoCache from '../noco-cache/NocoCache'; import NocoCache from '../noco-cache/NocoCache';
export default class GalleryView implements GalleryType { export default class GalleryView implements GalleryType {

3
packages/nocodb/src/lib/noco-models/HookFilter.ts

@ -1,7 +1,6 @@
import Noco from '../../lib/noco/Noco'; import Noco from '../../lib/noco/Noco';
import Model from './Model'; import Model from './Model';
import Column from './Column'; import Column from './Column';
import UITypes from '../sqlUi/UITypes';
import { import {
CacheDelDirection, CacheDelDirection,
CacheGetType, CacheGetType,
@ -9,7 +8,7 @@ import {
MetaTable MetaTable
} from '../utils/globals'; } from '../utils/globals';
import View from './View'; import View from './View';
import { FilterType } from 'nocodb-sdk'; import { FilterType, UITypes } from 'nocodb-sdk';
import NocoCache from '../noco-cache/NocoCache'; import NocoCache from '../noco-cache/NocoCache';
export default class Filter { export default class Filter {

10
packages/nocodb/src/lib/noco-models/Model.ts

@ -8,9 +8,9 @@ import {
ModelTypes, ModelTypes,
TableReqType, TableReqType,
TableType, TableType,
UITypes,
ViewTypes ViewTypes
} from 'nocodb-sdk'; } from 'nocodb-sdk';
import UITypes from '../sqlUi/UITypes';
import { import {
CacheDelDirection, CacheDelDirection,
CacheGetType, CacheGetType,
@ -425,12 +425,8 @@ export default class Model implements TableType {
); );
await ncMeta.metaDelete(null, null, MetaTable.MODELS, this.id); await ncMeta.metaDelete(null, null, MetaTable.MODELS, this.id);
await NocoCache.del( await NocoCache.del(`${CacheScope.MODEL}:${this.project_id}:${this.id}`);
`${CacheScope.MODEL}:${this.project_id}:${this.id}` await NocoCache.del(`${CacheScope.MODEL}:${this.project_id}:${this.title}`);
);
await NocoCache.del(
`${CacheScope.MODEL}:${this.project_id}:${this.title}`
);
return true; return true;
} }

2
packages/nocodb/src/lib/noco/common/BaseApiBuilder.ts

@ -32,7 +32,7 @@ import ncModelsOrderUpgrader from './jobs/ncModelsOrderUpgrader';
import ncParentModelTitleUpgrader from './jobs/ncParentModelTitleUpgrader'; import ncParentModelTitleUpgrader from './jobs/ncParentModelTitleUpgrader';
import ncRemoveDuplicatedRelationRows from './jobs/ncRemoveDuplicatedRelationRows'; import ncRemoveDuplicatedRelationRows from './jobs/ncRemoveDuplicatedRelationRows';
import xcMetaDiffSync from './handlers/xcMetaDiffSync'; import xcMetaDiffSync from './handlers/xcMetaDiffSync';
import UITypes from '../../sqlUi/UITypes'; import { UITypes } from 'nocodb-sdk';
const log = debug('nc:api:base'); const log = debug('nc:api:base');

2
packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts

@ -37,9 +37,9 @@ import { packageVersion } from 'nc-help';
import NcMetaIO, { META_TABLES } from './NcMetaIO'; import NcMetaIO, { META_TABLES } from './NcMetaIO';
import { promisify } from 'util'; import { promisify } from 'util';
import NcTemplateParser from '../../templateParser/NcTemplateParser'; import NcTemplateParser from '../../templateParser/NcTemplateParser';
import UITypes from '../../sqlUi/UITypes';
import { defaultConnectionConfig } from '../../utils/NcConfigFactory'; import { defaultConnectionConfig } from '../../utils/NcConfigFactory';
import xcMetaDiff from './handlers/xcMetaDiff'; import xcMetaDiff from './handlers/xcMetaDiff';
import { UITypes } from 'nocodb-sdk';
const randomID = customAlphabet('1234567890abcdefghijklmnopqrstuvwxyz_', 10); const randomID = customAlphabet('1234567890abcdefghijklmnopqrstuvwxyz_', 10);
const XC_PLUGIN_DET = 'XC_PLUGIN_DET'; const XC_PLUGIN_DET = 'XC_PLUGIN_DET';

4
packages/nocodb/src/lib/noco/meta/api/columnApis.ts

@ -1,6 +1,5 @@
import { Request, Response, Router } from 'express'; import { Request, Response, Router } from 'express';
import Model from '../../../noco-models/Model'; import Model from '../../../noco-models/Model';
import UITypes from '../../../sqlUi/UITypes';
import ProjectMgrv2 from '../../../sqlMgr/v2/ProjectMgrv2'; import ProjectMgrv2 from '../../../sqlMgr/v2/ProjectMgrv2';
import Base from '../../../noco-models/Base'; import Base from '../../../noco-models/Base';
import Column from '../../../noco-models/Column'; import Column from '../../../noco-models/Column';
@ -20,7 +19,8 @@ import {
isVirtualCol, isVirtualCol,
LinkToAnotherRecordType, LinkToAnotherRecordType,
RelationTypes, RelationTypes,
TableType TableType,
UITypes
} from 'nocodb-sdk'; } from 'nocodb-sdk';
import Audit from '../../../noco-models/Audit'; import Audit from '../../../noco-models/Audit';
import SqlMgrv2 from '../../../sqlMgr/v2/SqlMgrv2'; import SqlMgrv2 from '../../../sqlMgr/v2/SqlMgrv2';

3
packages/nocodb/src/lib/noco/meta/api/metaDiffApis.ts

@ -4,7 +4,7 @@ import ncMetaAclMw from '../helpers/ncMetaAclMw';
import Model from '../../../noco-models/Model'; import Model from '../../../noco-models/Model';
import Project from '../../../noco-models/Project'; import Project from '../../../noco-models/Project';
import NcConnectionMgrv2 from '../../common/NcConnectionMgrv2'; import NcConnectionMgrv2 from '../../common/NcConnectionMgrv2';
import { isVirtualCol, ModelTypes, RelationTypes } from 'nocodb-sdk'; import { isVirtualCol, ModelTypes, RelationTypes, UITypes } from 'nocodb-sdk';
import { Router } from 'express'; import { Router } from 'express';
import Base from '../../../noco-models/Base'; import Base from '../../../noco-models/Base';
import ModelXcMetaFactory from '../../../sqlMgr/code/models/xc/ModelXcMetaFactory'; import ModelXcMetaFactory from '../../../sqlMgr/code/models/xc/ModelXcMetaFactory';
@ -13,7 +13,6 @@ import LinkToAnotherRecordColumn from '../../../noco-models/LinkToAnotherRecordC
import { getUniqueColumnAliasName } from '../helpers/getUniqueName'; import { getUniqueColumnAliasName } from '../helpers/getUniqueName';
import NcHelp from '../../../utils/NcHelp'; import NcHelp from '../../../utils/NcHelp';
import getTableNameAlias, { getColumnNameAlias } from '../helpers/getTableName'; import getTableNameAlias, { getColumnNameAlias } from '../helpers/getTableName';
import UITypes from '../../../sqlUi/UITypes';
import mapDefaultPrimaryValue from '../helpers/mapDefaultPrimaryValue'; import mapDefaultPrimaryValue from '../helpers/mapDefaultPrimaryValue';
import { Tele } from 'nc-help'; import { Tele } from 'nc-help';
import getColumnUiType from '../helpers/getColumnUiType'; import getColumnUiType from '../helpers/getColumnUiType';

3
packages/nocodb/src/lib/noco/meta/api/projectApis.ts

@ -1,6 +1,6 @@
import { Request, Response } from 'express'; import { Request, Response } from 'express';
import Project from '../../../noco-models/Project'; import Project from '../../../noco-models/Project';
import { ModelTypes, ProjectListType } from 'nocodb-sdk'; import { ModelTypes, ProjectListType, UITypes } from 'nocodb-sdk';
import { PagedResponseImpl } from '../helpers/PagedResponse'; import { PagedResponseImpl } from '../helpers/PagedResponse';
import syncMigration from '../helpers/syncMigration'; import syncMigration from '../helpers/syncMigration';
@ -11,7 +11,6 @@ import NcHelp from '../../../utils/NcHelp';
import Base from '../../../noco-models/Base'; import Base from '../../../noco-models/Base';
import NcConnectionMgrv2 from '../../common/NcConnectionMgrv2'; import NcConnectionMgrv2 from '../../common/NcConnectionMgrv2';
import getTableNameAlias, { getColumnNameAlias } from '../helpers/getTableName'; import getTableNameAlias, { getColumnNameAlias } from '../helpers/getTableName';
import UITypes from '../../../sqlUi/UITypes';
import LinkToAnotherRecordColumn from '../../../noco-models/LinkToAnotherRecordColumn'; import LinkToAnotherRecordColumn from '../../../noco-models/LinkToAnotherRecordColumn';
import ncMetaAclMw from '../helpers/ncMetaAclMw'; import ncMetaAclMw from '../helpers/ncMetaAclMw';
import ProjectUser from '../../../noco-models/ProjectUser'; import ProjectUser from '../../../noco-models/ProjectUser';

3
packages/nocodb/src/lib/noco/meta/api/publicApis/publicMetaApis.ts

@ -2,8 +2,7 @@ import { Request, Response, Router } from 'express';
import catchError, { NcError } from '../../helpers/catchError'; import catchError, { NcError } from '../../helpers/catchError';
import View from '../../../../noco-models/View'; import View from '../../../../noco-models/View';
import Model from '../../../../noco-models/Model'; import Model from '../../../../noco-models/Model';
import UITypes from '../../../../sqlUi/UITypes'; import { ErrorMessages, LinkToAnotherRecordType, UITypes } from 'nocodb-sdk';
import { ErrorMessages, LinkToAnotherRecordType } from 'nocodb-sdk';
import Column from '../../../../noco-models/Column'; import Column from '../../../../noco-models/Column';
import Base from '../../../../noco-models/Base'; import Base from '../../../../noco-models/Base';
import Project from '../../../../noco-models/Project'; import Project from '../../../../noco-models/Project';

2
packages/nocodb/src/lib/noco/meta/handlersv2/ncCreateLookup.ts

@ -1,6 +1,6 @@
import { NcContextV2 } from '../NcMetaMgrv2'; import { NcContextV2 } from '../NcMetaMgrv2';
import Column from '../../../noco-models/Column'; import Column from '../../../noco-models/Column';
import UITypes from '../../../sqlUi/UITypes'; import { UITypes } from 'nocodb-sdk';
export default async function(this: NcContextV2, { args }: any) { export default async function(this: NcContextV2, { args }: any) {
if ( if (

49
packages/nocodb/src/lib/noco/migrationsv2/nc_011.ts

@ -878,27 +878,38 @@ const up = async knex => {
}; };
const down = async knex => { const down = async knex => {
// todo: update order based on relation and add missing drop statements await knex.schema.dropTable(MetaTable.MODEL_ROLE_VISIBILITY);
// TODO : delete relations await knex.schema.dropTable(MetaTable.PLUGIN);
await knex.schema.dropTable(MetaTable.PROJECT); await knex.schema.dropTable(MetaTable.AUDIT);
await knex.schema.dropTable(MetaTable.BASES); await knex.schema.dropTable(MetaTable.TEAM_USERS);
await knex.schema.dropTable(MetaTable.MODELS); await knex.schema.dropTable(MetaTable.TEAMS);
await knex.schema.dropTable(MetaTable.COLUMNS); await knex.schema.dropTable(MetaTable.ORGS);
await knex.schema.dropTable(MetaTable.COL_RELATIONS); await knex.schema.dropTable(MetaTable.PROJECT_USERS);
await knex.schema.dropTable(MetaTable.COL_RELATIONS); await knex.schema.dropTable(MetaTable.USERS);
await knex.schema.dropTable(MetaTable.FILTER_EXP);
await knex.schema.dropTable(MetaTable.SORT);
await knex.schema.dropTable(MetaTable.SHARED_VIEWS);
await knex.schema.dropTable(MetaTable.FORM_VIEW);
await knex.schema.dropTable(MetaTable.FORM_VIEW_COLUMNS);
await knex.schema.dropTable(MetaTable.GALLERY_VIEW);
await knex.schema.dropTable(MetaTable.GALLERY_VIEW_COLUMNS);
await knex.schema.dropTable(MetaTable.KANBAN_VIEW);
await knex.schema.dropTable(MetaTable.KANBAN_VIEW_COLUMNS); await knex.schema.dropTable(MetaTable.KANBAN_VIEW_COLUMNS);
await knex.schema.dropTable(MetaTable.KANBAN_VIEW);
await knex.schema.dropTable(MetaTable.COL_LOOKUP); await knex.schema.dropTable(MetaTable.GRID_VIEW_COLUMNS);
await knex.schema.dropTable(MetaTable.COL_FORMULA); await knex.schema.dropTable(MetaTable.GRID_VIEW);
await knex.schema.dropTable(MetaTable.GALLERY_VIEW_COLUMNS);
await knex.schema.dropTable(MetaTable.GALLERY_VIEW);
await knex.schema.dropTable(MetaTable.FORM_VIEW_COLUMNS);
await knex.schema.dropTable(MetaTable.FORM_VIEW);
await knex.schema.dropTable(MetaTable.SHARED_VIEWS);
await knex.schema.dropTable(MetaTable.SORT);
await knex.schema.dropTable(MetaTable.FILTER_EXP);
await knex.schema.dropTable(MetaTable.HOOK_LOGS);
await knex.schema.dropTable(MetaTable.HOOKS);
await knex.schema.dropTable(MetaTable.VIEWS); await knex.schema.dropTable(MetaTable.VIEWS);
await knex.schema.dropTable(MetaTable.COL_FORMULA);
await knex.schema.dropTable(MetaTable.COL_ROLLUP);
await knex.schema.dropTable(MetaTable.COL_LOOKUP);
await knex.schema.dropTable(MetaTable.COL_SELECT_OPTIONS);
await knex.schema.dropTable(MetaTable.COL_RELATIONS);
await knex.schema.dropTable(MetaTable.COLUMN_VALIDATIONS);
await knex.schema.dropTable(MetaTable.COLUMNS);
await knex.schema.dropTable(MetaTable.MODELS);
await knex.schema.dropTable(MetaTable.BASES);
await knex.schema.dropTable(MetaTable.PROJECT);
}; };
export { up, down }; export { up, down };

20
packages/nocodb/src/lib/noco/migrationsv2/nc_012_alter_column_data_types.ts

@ -5,22 +5,34 @@ const up = async (knex: Knex) => {
if (knex.client.config.client !== 'sqlite3') { if (knex.client.config.client !== 'sqlite3') {
await knex.schema.alterTable(MetaTable.COLUMNS, table => { await knex.schema.alterTable(MetaTable.COLUMNS, table => {
table.text('cdf').alter(); table.text('cdf').alter();
});
await knex.schema.alterTable(MetaTable.COLUMNS, table => {
table.text('dtxp').alter(); table.text('dtxp').alter();
});
await knex.schema.alterTable(MetaTable.COLUMNS, table => {
table.text('cc').alter(); table.text('cc').alter();
});
await knex.schema.alterTable(MetaTable.COLUMNS, table => {
table.text('ct').alter(); table.text('ct').alter();
}); });
} }
}; };
const down = async knex => { const down = async knex => {
await knex.schema.alterTable(MetaTable.COLUMNS, table => { if (knex.client.config.client !== 'sqlite3') {
if (knex.client.config.client !== 'sqlite3') { await knex.schema.alterTable(MetaTable.COLUMNS, table => {
table.string('cdf').alter(); table.string('cdf').alter();
});
await knex.schema.alterTable(MetaTable.COLUMNS, table => {
table.string('dtxp').alter(); table.string('dtxp').alter();
});
await knex.schema.alterTable(MetaTable.COLUMNS, table => {
table.string('cc').alter(); table.string('cc').alter();
});
await knex.schema.alterTable(MetaTable.COLUMNS, table => {
table.string('ct').alter(); table.string('ct').alter();
} });
}); }
}; };
export { up, down }; export { up, down };

66
packages/nocodb/src/lib/noco/upgrader/jobs/ncProjectUpgraderV2_0090000.ts

@ -4,10 +4,9 @@ import User from '../../../noco-models/User';
import Project from '../../../noco-models/Project'; import Project from '../../../noco-models/Project';
import ProjectUser from '../../../noco-models/ProjectUser'; import ProjectUser from '../../../noco-models/ProjectUser';
import Model from '../../../noco-models/Model'; import Model from '../../../noco-models/Model';
import { ModelTypes, ViewTypes } from 'nocodb-sdk'; import { ModelTypes, UITypes, ViewTypes } from 'nocodb-sdk';
import Column from '../../../noco-models/Column'; import Column from '../../../noco-models/Column';
import LinkToAnotherRecordColumn from '../../../noco-models/LinkToAnotherRecordColumn'; import LinkToAnotherRecordColumn from '../../../noco-models/LinkToAnotherRecordColumn';
import UITypes from '../../../sqlUi/UITypes';
import NcHelp from '../../../utils/NcHelp'; import NcHelp from '../../../utils/NcHelp';
import { substituteColumnAliasWithIdInFormula } from '../../meta/helpers/formulaHelpers'; import { substituteColumnAliasWithIdInFormula } from '../../meta/helpers/formulaHelpers';
import RollupColumn from '../../../noco-models/RollupColumn'; import RollupColumn from '../../../noco-models/RollupColumn';
@ -44,9 +43,9 @@ export default async function(ctx: NcUpgraderCtx) {
await projectBuilder.init(); await projectBuilder.init();
} }
await migrateUsers(ncMeta); const usersObj = await migrateUsers(ncMeta);
const projectsObj = await migrateProjects(ncMeta); const projectsObj = await migrateProjects(ncMeta);
await migrateProjectUsers(ncMeta); await migrateProjectUsers(projectsObj, usersObj, ncMeta);
const migrationCtx = await migrateProjectModels(ncMeta); const migrationCtx = await migrateProjectModels(ncMeta);
await migrateUIAcl(migrationCtx, ncMeta); await migrateUIAcl(migrationCtx, ncMeta);
@ -59,12 +58,13 @@ export default async function(ctx: NcUpgraderCtx) {
async function migrateUsers(ncMeta = Noco.ncMeta) { async function migrateUsers(ncMeta = Noco.ncMeta) {
const users = await ncMeta.metaList(null, null, 'xc_users'); const users = await ncMeta.metaList(null, null, 'xc_users');
const userList: User[] = []; const userObj: { [id: string]: User } = {};
for (const user of users) { for (const user of users) {
userList.push(await User.insert(user, ncMeta)); const user1 = await User.insert(user, ncMeta);
userObj[user1.id] = user1;
} }
return userList; return userObj;
} }
async function migrateProjects( async function migrateProjects(
@ -102,10 +102,20 @@ async function migrateProjects(
return projectsObj; return projectsObj;
} }
async function migrateProjectUsers(ncMeta = Noco.ncMeta) { async function migrateProjectUsers(
projectsObj: { [p: string]: Project },
usersObj: { [p: string]: User },
ncMeta = Noco.ncMeta
) {
const projectUsers = await ncMeta.metaList(null, null, 'nc_projects_users'); const projectUsers = await ncMeta.metaList(null, null, 'nc_projects_users');
for (const projectUser of projectUsers) { for (const projectUser of projectUsers) {
// skip if project is missing
if (!(projectUser.project_id in projectsObj)) continue;
// skip if user is missing
if (!(projectUser.user_id in usersObj)) continue;
await ProjectUser.insert( await ProjectUser.insert(
{ {
project_id: projectUser.project_id, project_id: projectUser.project_id,
@ -200,6 +210,7 @@ interface Formulav1 {
formula: { formula: {
value: string; value: string;
tree: any; tree: any;
error: string[] | string;
}; };
} }
@ -650,10 +661,20 @@ async function migrateProjectModels(
const colBody: any = { const colBody: any = {
_cn: columnMeta._cn _cn: columnMeta._cn
}; };
colBody.formula = await substituteColumnAliasWithIdInFormula( if (columnMeta?.formula?.error?.length) {
columnMeta.formula.value, colBody.error = Array.isArray(columnMeta.formula.error)
await model.getColumns(ncMeta) ? columnMeta.formula.error.join(',')
); : columnMeta.formula.error;
} else {
try {
colBody.formula = await substituteColumnAliasWithIdInFormula(
columnMeta.formula.value,
await model.getColumns(ncMeta)
);
} catch {
colBody.error = 'Invalid formula';
}
}
colBody.formula_raw = columnMeta.formula.value; colBody.formula_raw = columnMeta.formula.value;
const column = await Column.insert( const column = await Column.insert(
{ {
@ -1085,21 +1106,28 @@ async function migrateSharedViews(ctx: MigrateCtxV1, ncMeta: any) {
for (const sharedView of sharedViews) { for (const sharedView of sharedViews) {
let fk_view_id; let fk_view_id;
// if missing view name or model name skip the shared view migration
if (!sharedView.view_name || !sharedView.model_name) continue;
if (sharedView.view_type !== 'table' && sharedView.view_type !== 'view') { if (sharedView.view_type !== 'table' && sharedView.view_type !== 'view') {
fk_view_id = fk_view_id =
ctx.objViewRef[sharedView.project_id][sharedView.model_name][ ctx.objViewRef[sharedView.project_id]?.[sharedView.model_name]?.[
sharedView.view_name sharedView.view_name
].id; ]?.id;
} else { } else {
fk_view_id = fk_view_id =
ctx.objViewRef[sharedView.project_id][sharedView.model_name][ ctx.objViewRef[sharedView.project_id]?.[sharedView.model_name]?.[
ctx.objModelRef[sharedView.project_id][sharedView.model_name].title ctx.objModelRef[sharedView.project_id]?.[sharedView.model_name]?.title
].id || ]?.id ||
ctx.objViewRef[sharedView.project_id][sharedView.model_name][ ctx.objViewRef[sharedView.project_id]?.[sharedView.model_name]?.[
sharedView.model_name sharedView.model_name
].id; ]?.id;
} }
// if view id missing skip shared view migration
if (!fk_view_id) continue;
await View.update( await View.update(
fk_view_id, fk_view_id,
{ {

2
packages/nocodb/src/lib/sqlMgr/code/models/xc/BaseModelXcMeta.ts

@ -1,6 +1,6 @@
import BaseRender from '../../BaseRender'; import BaseRender from '../../BaseRender';
import UITypes from '../../../../sqlUi/UITypes';
import mapDefaultPrimaryValue from '../../../../noco/meta/helpers/mapDefaultPrimaryValue'; import mapDefaultPrimaryValue from '../../../../noco/meta/helpers/mapDefaultPrimaryValue';
import { UITypes } from 'nocodb-sdk';
abstract class BaseModelXcMeta extends BaseRender { abstract class BaseModelXcMeta extends BaseRender {
protected abstract _getAbstractType(column: any): any; protected abstract _getAbstractType(column: any): any;

1341
packages/nocodb/src/lib/sqlUi/MssqlUi.ts

File diff suppressed because it is too large Load Diff

1282
packages/nocodb/src/lib/sqlUi/MysqlUi.ts

File diff suppressed because it is too large Load Diff

947
packages/nocodb/src/lib/sqlUi/OracleUi.ts

@ -1,947 +0,0 @@
export class OracleUi {
static getNewTableColumns(): any[] {
return [
{
column_name: 'id',
dt: 'integer',
dtx: 'integer',
ct: 'int(11)',
nrqd: false,
rqd: true,
ck: false,
pk: true,
un: false,
ai: false,
cdf: null,
clen: null,
np: null,
ns: null,
dtxp: '',
dtxs: '',
altered: 1,
uidt: 'ID',
uip: '',
uicn: ''
},
{
column_name: 'title',
dt: 'varchar',
dtx: 'specificType',
ct: 'varchar(45)',
nrqd: true,
rqd: false,
ck: false,
pk: false,
un: false,
ai: false,
cdf: null,
clen: 45,
np: null,
ns: null,
dtxp: '45',
dtxs: '',
altered: 1,
uidt: 'SingleLineText',
uip: '',
uicn: ''
}
// {
// column_name:"created_at",
// dt: "timestamp",
// dtx: "specificType",
// ct: "varchar(45)",
// nrqd: true,
// rqd: false,
// ck: false,
// pk: false,
// un: false,
// ai: false,
// cdf: 'CURRENT_TIMESTAMP',
// clen: 45,
// np: null,
// ns: null,
// dtxp: '',
// dtxs: ''
// },
// {
// column_name:"updated_at",
// dt: "timestamp",
// dtx: "specificType",
// ct: "varchar(45)",
// nrqd: true,
// rqd: false,
// ck: false,
// pk: false,
// un: false,
// ai: false,
// cdf: 'CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP',
// clen: 45,
// np: null,
// ns: null,
// dtxp: '',
// dtxs: ''
// }
];
}
static getNewColumn(suffix) {
return {
column_name: 'title' + suffix,
dt: 'integer',
dtx: 'specificType',
ct: 'integer(11)',
nrqd: true,
rqd: false,
ck: false,
pk: false,
un: false,
ai: false,
cdf: null,
clen: 45,
np: null,
ns: null,
// data_type_x_specific: ' ',
dtxp: '11',
dtxs: ' ',
altered: 1,
uidt: 'Number',
uip: '',
uicn: ''
};
}
// static getDefaultLengthForDatatype(type) {
// switch (type) {
// case "int":
// return 11;
// break;
// case "tinyint":
// return 1;
// break;
// case "smallint":
// return 5;
// break;
//
// case "mediumint":
// return 9;
// break;
// case "bigint":
// return 20;
// break;
// case "bit":
// return 64;
// break;
// case "boolean":
// return '';
// break;
// case "float":
// return 12;
// break;
// case "decimal":
// return 10;
// break;
// case "double":
// return 22;
// break;
// case "serial":
// return 20;
// break;
// case "date":
// return '';
// break;
// case "datetime":
// case "timestamp":
// return 6;
// break;
// case "time":
// return '';
// break;
// case "year":
// return '';
// break;
// case "char":
// return 255;
// break;
// case "varchar":
// return 45;
// break;
// case "nchar":
// return 255;
// break;
// case "text":
// return '';
// break;
// case "tinytext":
// return '';
// break;
// case "mediumtext":
// return '';
// break;
// case "longtext":
// return ''
// break;
// case "binary":
// return 255;
// break;
// case "varbinary":
// return 65500;
// break;
// case "blob":
// return '';
// break;
// case "tinyblob":
// return '';
// break;
// case "mediumblob":
// return '';
// break;
// case "longblob":
// return '';
// break;
// case "enum":
// return '\'a\',\'b\'';
// break;
// case "set":
// return '\'a\',\'b\'';
// break;
// case "geometry":
// return '';
// case "point":
// return '';
// case "linestring":
// return '';
// case "polygon":
// return '';
// case "multipoint":
// return '';
// case "multilinestring":
// return '';
// case "multipolygon":
// return '';
// case "json":
// return ''
// break;
//
// }
//
// }
static getDefaultLengthForDatatype(type) {
switch (type) {
default:
return '';
}
}
static getDefaultLengthIsDisabled(type): any {
switch (type) {
case 'integer':
return true;
case 'bfile':
case 'binary rowid':
case 'binary double':
case 'binary_float':
case 'blob':
case 'canoical':
case 'cfile':
case 'char':
case 'clob':
case 'content pointer':
case 'contigous array':
case 'date':
case 'decimal':
case 'double precision':
case 'float':
case 'interval day to second':
case 'interval year to month':
case 'lob pointer':
case 'long':
case 'long raw':
case 'named collection':
case 'named object':
case 'nchar':
case 'nclob':
case 'number':
case 'nvarchar2':
case 'octet':
case 'oid':
case 'pointer':
case 'raw':
case 'real':
case 'ref':
case 'ref cursor':
case 'rowid':
case 'signed binary integer':
case 'smallint':
case 'table':
case 'time':
case 'time with tz':
case 'timestamp':
case 'timestamp with local time zone':
case 'timestamp with local tz':
case 'timestamp with timezone':
case 'timestamp with tz':
case 'unsigned binary integer':
case 'urowid':
case 'varchar':
case 'varchar2':
case 'varray':
case 'varying array':
return false;
}
}
static getDefaultValueForDatatype(type) {
switch (type) {
default:
return '';
}
}
static getDefaultScaleForDatatype(type): any {
switch (type) {
case 'integer':
case 'bfile':
case 'binary rowid':
case 'binary double':
case 'binary_float':
case 'blob':
case 'canoical':
case 'cfile':
case 'char':
case 'clob':
case 'content pointer':
case 'contigous array':
case 'date':
case 'decimal':
case 'double precision':
case 'float':
case 'interval day to second':
case 'interval year to month':
case 'lob pointer':
case 'long':
case 'long raw':
case 'named collection':
case 'named object':
case 'nchar':
case 'nclob':
case 'number':
case 'nvarchar2':
case 'octet':
case 'oid':
case 'pointer':
case 'raw':
case 'real':
case 'ref':
case 'ref cursor':
case 'rowid':
case 'signed binary integer':
case 'smallint':
case 'table':
case 'time':
case 'time with tz':
case 'timestamp':
case 'timestamp with local time zone':
case 'timestamp with local tz':
case 'timestamp with timezone':
case 'timestamp with tz':
case 'unsigned binary integer':
case 'urowid':
case 'varchar':
case 'varchar2':
case 'varray':
case 'varying array':
return ' ';
}
}
static colPropAIDisabled(col, columns) {
// console.log(col);
if (
col.dt === 'int4' ||
col.dt === 'integer' ||
col.dt === 'bigint' ||
col.dt === 'smallint'
) {
for (let i = 0; i < columns.length; ++i) {
if (columns[i].cn !== col.cn && columns[i].ai) {
return true;
}
}
return false;
} else {
return true;
}
}
static colPropUNDisabled(_col) {
// console.log(col);
return true;
// if (col.dt === 'int' ||
// col.dt === 'tinyint' ||
// col.dt === 'smallint' ||
// col.dt === 'mediumint' ||
// col.dt === 'bigint') {
// return false;
// } else {
// return true;
// }
}
static onCheckboxChangeAI(col) {
console.log(col);
if (
col.dt === 'int' ||
col.dt === 'bigint' ||
col.dt === 'smallint' ||
col.dt === 'tinyint'
) {
col.altered = col.altered || 2;
}
// if (!col.ai) {
// col.dtx = 'specificType'
// } else {
// col.dtx = ''
// }
}
static showScale(_columnObj) {
return false;
}
static removeUnsigned(columns) {
for (let i = 0; i < columns.length; ++i) {
if (
columns[i].altered === 1 &&
!(
columns[i].dt === 'int' ||
columns[i].dt === 'bigint' ||
columns[i].dt === 'tinyint' ||
columns[i].dt === 'smallint' ||
columns[i].dt === 'mediumint'
)
) {
columns[i].un = false;
console.log('>> resetting unsigned value', columns[i].cn);
}
console.log(columns[i].cn);
}
}
static columnEditable(colObj) {
return colObj.tn !== '_evolutions' || colObj.tn !== 'nc_evolutions';
}
static extractFunctionName(query) {
const reg = /^\s*CREATE\s+(?:OR\s+REPLACE\s*)?\s*FUNCTION\s+(?:[\w\d_]+\.)?([\w_\d]+)/i;
const match = query.match(reg);
return match && match[1];
}
static extractProcedureName(query) {
const reg = /^\s*CREATE\s+(?:OR\s+REPLACE\s*)?\s*PROCEDURE\s+(?:[\w\d_]+\.)?([\w_\d]+)/i;
const match = query.match(reg);
return match && match[1];
}
static splitQueries(query) {
/***
* we are splitting based on semicolon
* there are mechanism to escape semicolon within single/double quotes(string)
*/
return query.match(/\b("[^"]*;[^"]*"|'[^']*;[^']*'|[^;])*;/g);
}
static onCheckboxChangeAU(col) {
console.log(col);
// if (1) {
col.altered = col.altered || 2;
// }
// if (!col.ai) {
// col.dtx = 'specificType'
// } else {
// col.dtx = ''
// }
}
/**
* if sql statement is SELECT - it limits to a number
* @param args
* @returns {string|*}
*/
sanitiseQuery(args) {
let q = args.query.trim().split(';');
if (q[0].startsWith('Select')) {
q = q[0] + ` LIMIT 0,${args.limit ? args.limit : 100};`;
} else if (q[0].startsWith('select')) {
q = q[0] + ` LIMIT 0,${args.limit ? args.limit : 100};`;
} else if (q[0].startsWith('SELECT')) {
q = q[0] + ` LIMIT 0,${args.limit ? args.limit : 100};`;
} else {
return args.query;
}
return q;
}
getColumnsFromJson(json, tn) {
const columns = [];
try {
if (typeof json === 'object' && !Array.isArray(json)) {
const keys = Object.keys(json);
for (let i = 0; i < keys.length; ++i) {
switch (typeof json[keys[i]]) {
case 'number':
if (Number.isInteger(json[keys[i]])) {
columns.push({
dp: null,
tn,
cn: keys[i],
cno: keys[i],
dt: 'int',
np: 10,
ns: 0,
clen: null,
cop: 1,
pk: false,
nrqd: false,
rqd: false,
un: false,
ct: 'int(11) unsigned',
ai: false,
unique: false,
cdf: null,
cc: '',
csn: null,
dtx: 'specificType',
dtxp: '11',
dtxs: 0,
altered: 1
});
} else {
columns.push({
dp: null,
tn,
cn: keys[i],
cno: keys[i],
dt: 'float',
np: 10,
ns: 2,
clen: null,
cop: 1,
pk: false,
nrqd: false,
rqd: false,
un: false,
ct: 'int(11) unsigned',
ai: false,
unique: false,
cdf: null,
cc: '',
csn: null,
dtx: 'specificType',
dtxp: '11',
dtxs: 2,
altered: 1
});
}
break;
case 'string':
if (json[keys[i]].length <= 255) {
columns.push({
dp: null,
tn,
cn: keys[i],
cno: keys[i],
dt: 'varchar',
np: 45,
ns: 0,
clen: null,
cop: 1,
pk: false,
nrqd: false,
rqd: false,
un: false,
ct: 'int(11) unsigned',
ai: false,
unique: false,
cdf: null,
cc: '',
csn: null,
dtx: 'specificType',
dtxp: '45',
dtxs: 0,
altered: 1
});
} else {
columns.push({
dp: null,
tn,
cn: keys[i],
cno: keys[i],
dt: 'text',
np: null,
ns: 0,
clen: null,
cop: 1,
pk: false,
nrqd: false,
rqd: false,
un: false,
ct: 'int(11) unsigned',
ai: false,
unique: false,
cdf: null,
cc: '',
csn: null,
dtx: 'specificType',
dtxp: null,
dtxs: 0,
altered: 1
});
}
break;
case 'boolean':
columns.push({
dp: null,
tn,
cn: keys[i],
cno: keys[i],
dt: 'boolean',
np: 3,
ns: 0,
clen: null,
cop: 1,
pk: false,
nrqd: false,
rqd: false,
un: false,
ct: 'int(11) unsigned',
ai: false,
unique: false,
cdf: null,
cc: '',
csn: null,
dtx: 'specificType',
dtxp: '1',
dtxs: 0,
altered: 1
});
break;
case 'object':
columns.push({
dp: null,
tn,
cn: keys[i],
cno: keys[i],
dt: 'json',
np: 3,
ns: 0,
clen: null,
cop: 1,
pk: false,
nrqd: false,
rqd: false,
un: false,
ct: 'int(11) unsigned',
ai: false,
unique: false,
cdf: null,
cc: '',
csn: null,
dtx: 'specificType',
dtxp: null,
dtxs: 0,
altered: 1
});
break;
default:
break;
}
}
}
} catch (e) {
console.log('Error in getColumnsFromJson', e);
}
return columns;
}
static colPropAuDisabled(_col) {
return true;
}
static getAbstractType(col): any {
switch ((col.dt || col.dt).toLowerCase()) {
case 'integer':
return 'integer';
case 'bfile':
case 'binary rowid':
case 'binary double':
case 'binary_float':
return 'string';
case 'blob':
return 'blob';
case 'canoical':
case 'cfile':
case 'char':
case 'clob':
case 'content pointer':
case 'contigous array':
return 'string';
case 'date':
return 'date';
case 'decimal':
case 'double precision':
case 'float':
return 'float';
case 'interval day to second':
case 'interval year to month':
return 'string';
case 'lob pointer':
return 'string';
case 'long':
return 'integer';
case 'long raw':
return 'string';
case 'named collection':
case 'named object':
case 'nchar':
case 'nclob':
return 'string';
case 'nvarchar2':
case 'octet':
case 'oid':
case 'pointer':
case 'raw':
return 'string';
case 'real':
case 'number':
return 'float';
case 'ref':
case 'ref cursor':
case 'rowid':
case 'signed binary integer':
return 'string';
case 'smallint':
return 'integer';
case 'table':
return 'string';
case 'time':
case 'time with tz':
return 'time';
case 'timestamp':
case 'timestamp with local time zone':
case 'timestamp with local tz':
case 'timestamp with timezone':
case 'timestamp with tz':
return 'datetime';
case 'unsigned binary integer':
case 'urowid':
case 'varchar':
case 'varchar2':
return 'string';
case 'varray':
case 'varying array':
return 'string';
}
}
static getUIType(col): any {
switch (this.getAbstractType(col)) {
case 'integer':
return 'Number';
case 'boolean':
return 'Checkbox';
case 'float':
return 'Decimal';
case 'date':
return 'Date';
case 'datetime':
return 'CreateTime';
case 'time':
return 'Time';
case 'year':
return 'Year';
case 'string':
return 'SingleLineText';
case 'text':
return 'LongText';
case 'blob':
return 'Attachment';
case 'enum':
return 'SingleSelect';
case 'set':
return 'MultiSelect';
case 'json':
return 'LongText';
}
}
static getDataTypeForUiType(col) {
const colProp: any = {};
switch (col.uidt) {
case 'ID':
colProp.dt = 'integer';
colProp.pk = true;
colProp.un = true;
colProp.ai = true;
colProp.rqd = true;
break;
case 'ForeignKey':
colProp.dt = 'varchar';
break;
case 'SingleLineText':
colProp.dt = 'varchar';
break;
case 'LongText':
colProp.dt = 'clob';
break;
case 'Attachment':
colProp.dt = 'clob';
break;
case 'Checkbox':
colProp.dt = 'tinyint';
colProp.dtxp = 1;
break;
case 'MultiSelect':
colProp.dt = 'varchar2';
break;
case 'SingleSelect':
colProp.dt = 'varchar2';
break;
case 'Collaborator':
colProp.dt = 'varchar';
break;
case 'Date':
colProp.dt = 'varchar';
break;
case 'Year':
colProp.dt = 'year';
break;
case 'Time':
colProp.dt = 'time';
break;
case 'PhoneNumber':
colProp.dt = 'varchar';
colProp.validate = {
func: ['isMobilePhone'],
args: [''],
msg: ['Validation failed : Invalid Mobile Format']
};
break;
case 'Email':
colProp.dt = 'varchar';
colProp.validate = {
func: ['isEmail'],
args: [''],
msg: ['Validation failed : Invalid Email Format']
};
break;
case 'URL':
colProp.dt = 'varchar';
colProp.validate = {
func: ['isURL'],
args: [''],
msg: ['Validation failed : Invalid URL Format']
};
break;
case 'Number':
colProp.dt = 'integer';
break;
case 'Decimal':
colProp.dt = 'decimal';
break;
case 'Currency':
colProp.dt = 'decimal';
colProp.validate = {
func: ['isCurrency'],
args: [''],
msg: ['Validation failed : Invalid Currency Format']
};
break;
case 'Percent':
colProp.dt = 'double';
break;
case 'Duration':
colProp.dt = 'integer';
break;
case 'Rating':
colProp.dt = 'float';
break;
case 'Formula':
colProp.dt = 'varchar';
break;
case 'Rollup':
colProp.dt = 'varchar';
break;
case 'Count':
colProp.dt = 'integer';
break;
case 'Lookup':
colProp.dt = 'varchar';
break;
case 'DateTime':
colProp.dt = 'timestamp';
break;
case 'CreateTime':
colProp.dt = 'timestamp';
break;
case 'LastModifiedTime':
colProp.dt = 'timestamp';
break;
case 'AutoNumber':
colProp.dt = 'integer';
break;
case 'Barcode':
colProp.dt = 'varchar';
break;
case 'Button':
colProp.dt = 'varchar';
break;
default:
colProp.dt = 'varchar';
break;
}
return colProp;
}
static getUnsupportedFnList() {
return [];
}
}
// module.exports = PgUiHelp;
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

1970
packages/nocodb/src/lib/sqlUi/PgUi.ts

File diff suppressed because it is too large Load Diff

70
packages/nocodb/src/lib/sqlUi/SqlUiFactory.ts

@ -1,70 +0,0 @@
import { MysqlUi } from './MysqlUi';
import { PgUi } from './PgUi';
import { MssqlUi } from './MssqlUi';
import { OracleUi } from './OracleUi';
import { SqliteUi } from './SqliteUi';
// import {YugabyteUi} from "./YugabyteUi";
// import {TidbUi} from "./TidbUi";
// import {VitessUi} from "./VitessUi";
export class SqlUiFactory {
static create(connectionConfig) {
// connectionConfig.meta = connectionConfig.meta || {};
// connectionConfig.meta.dbtype = connectionConfig.meta.dbtype || "";
if (
connectionConfig.client === 'mysql' ||
connectionConfig.client === 'mysql2'
) {
// if (connectionConfig.meta.dbtype === "tidb")
// return Tidb;
// if (connectionConfig.meta.dbtype === "vitess")
// return Vitess;
console.log('- - - -In Mysql UI');
return MysqlUi;
}
if (connectionConfig.client === 'sqlite3') {
return SqliteUi;
}
if (connectionConfig.client === 'mssql') {
return MssqlUi;
}
if (connectionConfig.client === 'oracledb') {
return OracleUi;
}
if (connectionConfig.client === 'pg') {
// if (connectionConfig.meta.dbtype === "yugabyte")
// return Yugabyte;
return PgUi;
}
throw new Error('Database not supported');
}
}
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

1114
packages/nocodb/src/lib/sqlUi/SqliteUi.ts

File diff suppressed because it is too large Load Diff

39
packages/nocodb/src/lib/sqlUi/UITypes.ts

@ -1,39 +0,0 @@
enum UITypes {
ID = 'ID',
LinkToAnotherRecord = 'LinkToAnotherRecord',
ForeignKey = 'ForeignKey',
Lookup = 'Lookup',
SingleLineText = 'SingleLineText',
LongText = 'LongText',
Attachment = 'Attachment',
Checkbox = 'Checkbox',
MultiSelect = 'MultiSelect',
SingleSelect = 'SingleSelect',
Collaborator = 'Collaborator',
Date = 'Date',
Year = 'Year',
Time = 'Time',
PhoneNumber = 'PhoneNumber',
Email = 'Email',
URL = 'URL',
Number = 'Number',
Decimal = 'Decimal',
Currency = 'Currency',
Percent = 'Percent',
Duration = 'Duration',
Rating = 'Rating',
Formula = 'Formula',
Rollup = 'Rollup',
Count = 'Count',
DateTime = 'DateTime',
CreateTime = 'CreateTime',
LastModifiedTime = 'LastModifiedTime',
AutoNumber = 'AutoNumber',
Geometry = 'Geometry',
JSON = 'JSON',
SpecificDBType = 'SpecificDBType',
Barcode = 'Barcode',
Button = 'Button'
}
export default UITypes;

8
packages/nocodb/src/lib/sqlUi/index.ts

@ -1,8 +0,0 @@
// todo: move to a common library
export * from './MysqlUi';
export * from './PgUi';
export * from './MssqlUi';
export * from './OracleUi';
export * from './SqliteUi';
export * from './SqlUiFactory';

6
packages/nocodb/src/lib/templateParser/NcTemplateParser.ts

@ -4,9 +4,9 @@ import {
OracleUi, OracleUi,
PgUi, PgUi,
SqliteUi, SqliteUi,
SqlUiFactory SqlUiFactory,
} from '../sqlUi'; UITypes
import UITypes from '../sqlUi/UITypes'; } from 'nocodb-sdk';
export default class NcTemplateParser { export default class NcTemplateParser {
sqlUi: sqlUi:

6
scripts/cypress/fixtures/sqlite-sakila/regenFiles/package-lock.json generated

@ -460,9 +460,9 @@
} }
}, },
"minimist": { "minimist": {
"version": "1.2.5", "version": "1.2.6",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q=="
}, },
"minipass": { "minipass": {
"version": "2.9.0", "version": "2.9.0",

Loading…
Cancel
Save