64 Commits

Author SHA1 Message Date
Lookin Anton
190191a75d fix(packages:schema): fix bindings for postgres dialect in overview method (#13115) 2022-05-09 16:42:09 -04:00
Aiden Foxx
2feb47c629 Use older Oracle optimizer features for better data dictionary performance (#13076) 2022-05-02 10:19:30 -04:00
Rijk van Zanten
c01f507696 Use correct import for crdb dialect from schema-inspector (#11269)
Fixes #11266
2022-01-25 15:08:20 -05:00
Rijk van Zanten
88c87f3920 Set CRDB options to avoid inconsistencies between vendors (#11193)
* Set correct CRDB options

* Add missing SETs to pool config for e2e

* How about now

* Better solution for the same problem
2022-01-20 20:18:22 -05:00
Michael Schramm
75b5f33727 Implement CockroachDB support (#10113)
* base changes for cockroachdb

* allow creating of tables

* allow deleting of fields

* allow deleting of tables

* rebase

* fix migrations

* bump knex-schema-inspector to 1.7.0

* Update package-lock

* Add cockroach to debugging docker-compose file

* Remove unused import

* Tweak name in example.env

* Force nullable primary keys in cockroach

* Tweak shares migration to run on cockroach

* Rename var for clarification

* suggestion for migration helper

* change to schema and update remaining migrations

* Remove custom cockroach schema in favor of sharing with pg

* Fix migrations for CockroachDB

* Hopefully fix Oracle migrations 🤞🏻

* Make ~~aiden~~ oracle happy

* Resolve branching paths in migrations

* Enable tests for cockroach

* Fix test config

* One more config change for good measure

* Adjust test to match cockroach's bigint auto-int structure

* Increase request timeout for mssql

* Update api/src/database/helpers/schema/types.ts

Co-authored-by: Aiden Foxx <aiden.foxx.mail@gmail.com>

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
Co-authored-by: Oreille <33065839+Oreilles@users.noreply.github.com>
Co-authored-by: Aiden Foxx <aiden.foxx.mail@gmail.com>
2022-01-20 14:14:38 -05:00
Oreille
525e2548b4 Fix compatibility with Postgres <= 10 (#10139)
* Use indnatts instead of indnkeyatts in postgres dialect

* Update knex-schema-inspector

* Add PG10 for debugging

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2021-12-01 20:36:46 +00:00
Oreille
94985d547a Fix MySQL tinyint(1) not being treated as boolean (#10083) 2021-12-01 14:01:48 -05:00
Aiden Foxx
c2f3442697 Cleaned up Oracle duplicate index handling (#10151)
* Update oracledb.ts

* Update packages/schema/src/dialects/oracledb.ts

* Update packages/schema/src/dialects/oracledb.ts
2021-12-01 13:58:37 -05:00
Nitwel
b3c8941645 fix mysql duplicates (#10057) 2021-11-25 16:50:19 +00:00
Aiden Foxx
f19a549a1b Handle composite primary keys (#9822)
* Handle composite keys in Oracle

* Handle composite primary keys in PostgreSQL

* Handle composite primary keys in SQL Server

* Handle composite primary keys in SQLite

* Added Oracle performance notice

* Handle composite primary keys in MySQL

* Make the linter happy

Co-authored-by: Oreilles <oreilles.github@nitoref.io>
2021-11-24 16:10:34 -05:00
Aiden Foxx
cbe87299c7 Exclude hidden oracle columns (#9677) 2021-11-10 10:31:43 -05:00
Oreille
5f43b20ebf Update geometric types and patch new field flow. (#9397)
* Update geometric types and patch new field flow.

* Add migration

* Fixed migrations

* Also fixed migrations

* Update migration ID

* Cleanup type selector a bit

* Add missing fallback interface/display for new types

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2021-11-04 21:47:54 -04:00
Aiden Foxx
b834bf88a7 Update Oracle to support is_generated (#9310) 2021-11-01 16:04:41 +00:00
Oreille
e316948e5f Removed invalid column in mssql schema inspector (#9260) 2021-10-30 15:24:43 -04:00
Oreille
8df071a3a2 Fix generated columns being required. (#9200)
* Fix generated columns being required. Also prevent schema changes on generated columns.

* Fix type errors

* Disable `unique` and `nullable` instead of not showing them.

* Fix other type error

* Nullable check small refactor

* Fixed MSSQL query

* Fixed oracle query
2021-10-29 12:24:21 -04:00
José Varela
3124f5387d Fix getSchema while trx on postgres (#8335)
* Fix getSchema while trx on postgres

* Only attempt to read geometry types when PostGIS is enabled

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2021-09-27 16:35:01 -04:00
Nicola Krumschmidt
d64ca14348 Explicitly set catch parameters to any type (#7654)
This fixes not being able to build the repo due to type issues
introduced by the Typescript 4.4 option "useUnknownInCatchVariables",
which is enabled by default in strict mode.
2021-08-27 10:33:30 -04:00
Oreille
fb64df54be Fix server error when a postgres view contains geometry columns (#7487)
* Fix server error when a postgres view contains geometry columns

* Fixed typo

Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
2021-08-18 15:19:12 -04:00
Oreille
02cf1741bb Fix server error when a postgres view contains geometry columns (#7486) 2021-08-18 15:14:46 +02:00
Oreille
83e8814b2d Add support for Geometry type, add Map Layout & Interface (#5684)
* Added map layout

* Cleanup and bug fixes

* Removed package-lock

* Cleanup and fixes

* Small fix

* Added back package-lock

* Saved camera, autofitting option, bug fixes

* Refactor and ui improvements

* Improvements

* Added seled mode

* Removed unused dependency

* Changed selection behaviour, cleanup.

* update import and dependencies

* make custom style into drawer

* remove unused imports

* use lodash functions

* add popups

* allow header to become small

* reorganize settings

* add styling to popup

* change default template

* add projection option

* add basic map interface

* finish simple map

* add mapbox style

* support more mapbox layouts

* add api key option

* add mapbox backgrounds to layout

* warn when no api key is set

* fix for latest version

* Improved map layout and interface, bug fixes, refactoring.

.

.

* Added postgis geometry format, added marker icon shadow

* Made map buttons bigger and their icons thinner. Added transition to header bar.

* Bug fixes and error handling in map interface.

* Moved box-select control out of the map component. Removed material icons sprite and use addImage for marker support.

* Handle MultiGeometry -> Geometry interface error.

* Removed hardcoded styles. Added migrations for basemap column. Lots of refactoring.

Removed hardcoded styles. Added migrations for basemap column. Lots of refactoring.

* Fixed style reloading error. Added translations.

* Moved worker code to lib.

* Removed worker code. Prevent Mapbox from removing access_token from the URL.

* Refactoring.

* Change basemap selection to in-map dropdown for layout and interface.

* Touchscreen selection support and small fixes.

* Small change.

* Fixed unused imports.

* Added support for PostgreSQL identity column

* Renamed migration. Added crs translation.

* Only show fields using the map interface in the map layout.

* Removed logging.

* Reverted Dockerfile change.

* Improved crs support.

* Fixed translations.

* Check for schema identity before updating it.

* Fixed popup not updating on feature hover.

* Added feature hover styling. Fixed layer customization input. Added out of bounds error handling.

* Added geometry type and support for database native geometries.

* Fixed linting.

* Fixed layout.

* Fixed layout.

* Actually fixed linting

* Full support for native geometries
Fixed basemap input
Improved feature popup on hover
Locked interfaced support

* Fixed geometryType option not updating

* Bug fixes in interface

* Fixed crash when empty basemap settings. Fixed fitBounds option not updating.

* Added back storage type option. Improved interface behaviour.

* Dropped wkb because of vendor inconsistency with binary data

* Updated layout to match new geometry type. Fixed geojson payload transform.

* Added missing geometry_format attributes to local types.

* Fixed typos & refactoring

* Removed dependency on proj4

* Fix error when empty map interface options

* Set geometry SRID to 4326 when inserting into the database

* Add support for selectMode

* Fix error on initial source load

* Added geocoder, use GeoJSON for api i/o, removed geometry_format option, refactoring

* Added geometry intersects filter. Created geometry helper class.

* Fix error when null geometryOptions, added mapbox_key setting.

* Moved all geometry parsing/serializing into processGeometries in `payload.ts`. Fixed type errors.

* Migrate to Vue 3

* Use wellknown instead of wkx

* Fixed basemap selection.

* Added available operator for geometry type

* Added nintersects filter, fixed map interface for filter input

* Added intersects_bbox filter & bug fixes.

* Fixed icons rendering

* Fixed cursor icon in select mode

* Added geometry aggregate function

* Fixed geometry processing bug when imported from relational field.

* Fixed error with geocoder instanciation

* Removed @types/maplibre-gl dependency

* Removed fitViewToData options

* Merge remote-tracking branch 'upstream/main' into map-layout

* Fixed style and geometryType in map interface options

* Fixed style change on map interface.

* Improved fitViewToData behaviour

* Fixed type imports and previous merge conflict

* Fixed linting

* Added available operators

* Fix and merge migrations

* Remove outdated p-queue dep

* Fix get-schema column extract

* Replace pg with postgis for local debugging

* Re-add missing import

* Add mapbox as a basemap when key exists

* Remove unused tz flag

* Process delta in payloadservice

* Set default map, add limit number styling

* Default display template to just PK

* Tweak styling of error dialog

* Fix method usage in helpers

* Move sdo_geo to oracle section

* Remove extensions from ts config exclude

* Move geo types to shared, remove _Geometry

* Remove unused type

* Tiny Tweaks

* Remove fit to bounds option in favor of on

* Validate incoming intersects query

* Deepmap filter values

* Add GraphQL support

* No defaultValue for geometryType

* Resolve c

* Fix translations

Co-authored-by: Nitwel <nitwel@arcor.de>
Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
2021-08-12 22:01:34 +02:00
Aiden Foxx
27037f95c7 Fix quotes with schema default values (#6968)
* Added quote trimming to schema default values

* Add return type to stripQuotes function

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2021-07-26 16:37:45 +00:00
Aiden Foxx
6283b649f5 Removed lowercase remap from Oracle schema (#6214) 2021-06-11 12:54:46 -04:00
Aiden Foxx
ec72249ab5 Optimized oracle schema overview query (#6211)
* Optimized oracle schema overview query

* Fixed oracle overview query indentation
2021-06-11 11:22:59 -04:00
rijkvanzanten
2cce775784 Fix sqlite import 2021-06-03 23:40:34 -04:00
Rijk van Zanten
fe6101cfd3 Fix unsigned data type reading in MSSQL (#6058)
Fixes #5999
2021-06-03 23:11:15 -04:00
Rijk van Zanten
85d33d9ffc Fixed an issue that would cause "text" fields to show up as varchar with length -1 in MS SQL (#6055)
Fixes #5944
2021-06-03 22:35:07 -04:00
Matteo Gazzoni
32f4fcf0c7 select only real tables (and not views) in mssql (#5816)
* select only real tables (and not views) in mssql

* add table_catalog check

* Add changeset

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2021-05-21 21:11:19 +00:00
Rijk van Zanten
9335372400 Foreign Key Constraints (#5615)
* Bump knex-schema-inspector

* Fix cli role name attr

* Update relation type

* Restructure relations

* Restructure relations table

* Update api type for relation record

* Fetch relations in new structure

* Update schema-inspector

* Use new relations schema structure in api

* Update relations GETters

* Add default value to one deselect

* Add create relationship on existing field

* Add updating existing relationship

* Add delete relations

* Add relations query resolver

* Add graphql mutations for relations

* Fix reading from wrong name

* Fix wrong method name

* No idea why this flip flops every install

* Update relation type

* Accept null in use-collection composable

* Use new relations structure in translations

* Use new relations structure in new-collection

* Start updating field detail store

* Renames for new relations structure

* Silently ignore passed collection/field in relation update

* Fix setting pk field in m2o relational setup

* Small tweaks in o2m setup

* Fix m2m setup

* Tweak m2o setup

* Fix m2a setup

* Allow null for related collection (m2a)

* Fix languages code name

* Fix migration default value

* Fix relational cleanup in collections/fields

* Fix transaction problem in field delete

* Fix inserting relational o2m items

* Don't execute updateByQuery on empty item set

Fixes #5710, fixes #5070

* Show referential action input on m2o

* Finish language for m2o

* Show triggers config on o2m

* Delete items on one_deselect_item delete

* Fix naming, show relational trigger config on m2m

* Tweak language, add setup to m2a

* Fix linter warnings

* Add trigger setup for translations

* fix Edit non-schema relationship issue

* Sync existing on_delete triggers in o2m setup

* Add migration to setup foreign key constraints

* Update illegal FK values before setting constraint

* Fix MySQL unsigned vs not-unsigned in FK creation

* Use pretty names for labels in relational triggers

* Prefix auto-junction when system table

Fixes #5493

* Add system foreign key triggers

Fixes #5749

* Update docs
2021-05-19 12:29:16 -04:00
rijkvanzanten
8e8f93ac62 Pull parseDefaultValue from new location
Fixes #5733
2021-05-17 15:36:39 -04:00
Oreille
da1c3ed9a3 Added support for PostgreSQL identity column (#5502) 2021-05-05 17:52:41 -04:00
Aiden Foxx
f9a01d6684 [OracleDB] Extended schema-inspector to add AUTO_INCREMENT to columnInfo (#5408)
* Extended knex to add AUTO_INCREMENT to oracle columnInfo

* TS: Added missing return type
2021-05-03 09:34:45 -04:00
rijkvanzanten
801e868554 Fix remaining eslint errors
h/t @paescuj
2021-04-29 15:55:12 -04:00
Pascal Jufer
acd41eb0be Syntax fixes (#5367)
* Declare return types on functions

And a very few other type related minor fixes

* Minor syntax fixes

* Remove unnecessary escape chars in regexes
* Remove unnecessary awaits
* Replace deprecated req.connection with req.socket
* Replace deprecated upload with uploadOne
* Remove unnecessary eslint-disable-next-line comments
* Comment empty functions / catch or finally clauses
* Fix irregular whitespaces
* Add missing returns (null)
* Remove unreachable code
* A few logical fixes
* Remove / Handle non-null assertions which are certainly unnecessary (e.g. in
tests)
2021-04-29 12:11:43 -04:00
Aiden Foxx
da826e2a1a Update oracledb.ts (#5331)
As explained in the code comment, Oracle doesn't return "AUTO_INCREMENT", causing `authorization.ts` to throw a error that primary keys are required values.
2021-04-28 14:07:15 -04:00
Aiden Foxx
dc973d37f4 Update oracledb.ts (#5327)
As defined by Oracle, NULLABLE should return "Y" or "N":

https://docs.oracle.com/cd/B19306_01/server.102/b14237/statviews_2094.htm
2021-04-28 14:53:17 +00:00
rijkvanzanten
c4e1e40279 Fix @directus/schema not reading Oracle overview correctly
Fixes #4735
2021-04-09 19:28:00 -04:00
Stephen O'Connor
bb9b39187b Remove semi-colon to avoid ORA-00933 (#4726) 2021-03-29 08:59:34 -04:00
rijkvanzanten
340aa2deef Fix MySQL not correctly scoping columns to database 2021-03-16 11:26:57 -04:00
Adrian Dimitrov
51a0044d7f In mysql, select only tables (#4501) 2021-03-12 18:12:18 -05:00
Martijn Boland
9897e3d39e Added 'AUTO_INCREMENT' for mssql identity columns (#4494)
* Added 'AUTO_INCREMENT' for mssql identity columns

* Removed obsolete method

Co-authored-by: Martijn Boland <martijn@taiga.nl>
2021-03-11 18:09:06 -05:00
Rijk van Zanten
971a18c219 Database Error Abstraction (#4465)
* Start on database-error abstraction layer

* Add SQLite error abstraction

* Enable SQLite foreign key support

* Cleanup sqlite dialect slightly

Does it matter? Not really!

* Add MySQL error abstraction

* WIP Almost done with MSSQL

* Add correct error handling for MS SQL

* Fix mysql errors by not relying on value order

* Don't rely on sql in postgres exception translation

* Fix sqlite error parsing

* Remove foreign key constraint from activity to collections

A collection can be DB-only, but we still want to track activity for non-meta collections

* Translate error on update as well
2021-03-10 17:16:15 -05:00
Rijk van Zanten
97dcdad847 OracleDB baby steps (#4464)
* Allow external connections in oracle debug

* Fix oracle overview query

* Use correct alive check for oracle

* Remove unused import

* Validate correct env vars for oracle
2021-03-10 16:58:49 -05:00
Rijk van Zanten
291643e0b4 Fix installing on MS SQL (#4455)
Fixes #3158, fixes #3608
2021-03-09 18:43:03 -05:00
Rijk van Zanten
1db99e0828 Cleanup schema inspector (#4404)
* Rely on knex-schema-inspector

* Update packages
2021-03-05 17:06:07 -05:00
Nicola Krumschmidt
08293b8570 Update Knex to version 0.95.0 (#4374)
* Update Knex to version 0.95.0

* Fix formatting in schema dialects

* Fix Knex imports

* Update package-lock

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2021-03-03 19:37:44 -05:00
rijkvanzanten
eb4deaa955 Default field sort order to database ordinal sort
And use alphabetical where appropriate

Fixes #4341
2021-03-03 18:36:21 -05:00
Kim Streich
c30078369a Fix MS SQL init failure due to uquoted DB name 2021-01-23 20:13:43 +04:00
rijkvanzanten
ea3fb22322 Wrap db name
Fixes #3607
2021-01-13 16:07:05 -05:00
rijkvanzanten
7032eb4797 Check for both column key and constraint name
Fixes #3322
2021-01-12 17:59:16 -05:00
Rijk van Zanten
fd99c2d3ef Merge pull request #3250 from nickrum/postgres-nullable-fix
Fix nullable property of Postgres schema overview
2020-11-30 18:32:36 -05:00