This PR adds index CREATE and trigger CREATE scripts to the table CREATE script. In the process the following was also changed/updated:
- Trigger templates updated
- Tests for scripting on tables updated to include checks for index and trigger scripts
- Test for trigger updated to use `FUNCTION` instead of `PROCEDURE` because mock server is version 13. The version 13 template uses `FUNCTION` instead
- Index create scripts include `IF NOT EXISTS`
- The metadata.schema value for Indexes and Triggers stores `f'{schema}.{table_or_view_name}'`
- Triggers are now scriptable
- The way Indexes are fetched during scripting is slightly different than before, but more similar to how Triggers are fetched. This is because they are both table_objects
- Indexes are now scriptable even under materialized views
* reconnect if broken
* update naming
* retry for broken connection during request
* change name of SCRIPTAS_REQUEST
* expand node broken connection
* reconnect during refresh if needed
* lint fix
* test fix init
* none checks for tests
* fix connection during errors
* return after script request exception
* use mock connection for server in test
* put back try catch block for node expansion
* validate error
* mock server
* mock server
* Revert "mock server"
This reverts commit 2cdeeea68f.
* Revert "put back try catch block for node expansion"
This reverts commit a87a34b52e.
* retry state
* add back exception in expand node base
* lint error
- Updated template files ensuring
- add PgAdmin License header
- change data.func_without_args to data.func_args
- macros are being pathed to properly
- Using `.server` instead of `._server` outside of NodeObject class
- Added conn to FunctionBase query_data methods
Addresses issues described in microsoft/azuredatastudio-postgresql#452 and microsoft/azuredatastudio-postgresql#453.
- Indexes should now show scripting options regardless of if they are unique or not
- Indexes will not show primary key, but this will show up in constraints. This is following the pattern of PgAdmin
- Constraints should properly show the associated constraints
1. Check constraints
2. Exclusion constraints
3. Index constraints (primary key and unique key)
4. Foreign key constraints
- Template files were updated for all constraint types
* initial commit
* started to fix style check and tests
* check to see if parent hasattr of schema
* is_sort_nulls_applicable should always be set to true
Fixes create script for functions such that:
- Syntax is correct for immediate execution
- Function body is included for all versions (< 14 and >= 14)
- Should work for procedures and functions
Some template files needed to be changed slightly to prevent using the full properties that are generated for functions in pgAdmin.
* Stream line the pg scripts
* Bug fixes for PG 10 OE errors and System object scripting
* Bug fixes for PG 10 OE errors and System object scripting
* Bug fixes for PG 10 OE errors and System object scripting
* PG SQL Object Model #1775 - OE System Folders
* PG SQL Object Model #1775 - OE System Folders
* PG SQL Object Model #1775 - OE System Folders
* PG SQL Object Model #1775 - OE System Folders
* init index.py file
* init test_object_index.py file
* init test_scripter.py file
* init index & change of test framework
* init index & change of test framework - 2
* small fix - styling
* small fix - 3
This commit integrates the bulk of the PG-CLI code for auto-completion into our codebase. Putting this out as its own PR for clarity, since the separate work to integrate into the language service will be much smaller. The code has been changed to:
- Avoid supporting CLI-only special syntax
- Make unit tests support the unittest framework rather than pytest
- Integrate with PGSMO in the CompletionRefresher class
**Additional changes**
Added a ThirdPartyNotices.txt with our 2 codebases we're using directly in the code. We'll also want to update this to a) be included in the bundle so it's installed on disk with the exe, and b) add in any module dependencies used at runtime (not test dependencies)
Notes
**Notes**
The code under pgsqltoolsservice\language\completion has been minimally changed from PG-CLI, and should be updatable in the future for changes. Similarly, unit tests under tests\language\completion have been changed from pytest to nosetest + parameterized.
Long-term will look at whether we can go to a direct pg-cli dependency but this requires investigation re: only building in the modules we need, since it has a lot of extra dependencies, and filtering out / avoiding paths where the special CLI handling is processed. These are candidates for submitting back as config options to their codebase once we're public, since at that point they might be willing to take this and let us factor this cleanly out.
* DB support
* DB changes
* PG OE2
* merge2
* Merge with UTC
* PG OE
* UTC
* Merge master 2
* PG OE
* PE OE Master Merge
* PG OE Server Close connection
* PG OE Master merge bugs fix
* PG OE Master merge bugs fix2
* code changes
* check node type
* PG OE with callback function
* Shutdown test case
* clean test case
* PE OE refactoring
* PE OE refactoring2
* flakes
* PE OE refactoring Unit test cases
* closing db connections
* PG OE PR comments
* Removing property oid
* Placing a not for node_object
Fixed the feedback except the using psycopg2 for generating the queries. We use the mogrify for psycopg which expects the query template to be in certain format. As of now we manually handle escaping any column names of table names. But I will make this change to use SQL from the psycopg2
* Initial implementation of URNs for objects
* Lookup logic for URNs
* URN generation logic
* Update to _register_child_collection to map class name to collection, allowing URN lookup implementation in NodeObject
* Tweaks to make it work!
* Wiring it up to the scripting service
* Hacking in support for SELECT
* Unit tests work!
* Adding tests for urn generation
* Adding tests for get_obj_by_urn in server
* Adding tests for getting object by URN at the object level
* Fixing broken unit tests for scripting service
* Adding test for urn utilities
* Flake8 stuff and things
* Mixins for collation work!
* Create mixins for most other things work. Lots of futsing with the unit tests
* Creating mixin for delete
* Creating mixin for update
* Adding unittests for scripting mixins
* Adding unittests for mixins in the classes
Fixing Collation unittests
* Fixing smo edit table metadata tests
* Patching up datatype, disabling mixin testing in the node_base
* Flake8 stuff
* Fixes as per Matt's PR comments
* Rewriting unit tests for scripting service
* Fixing template renderer as per PR comments
Adding tests for template rendering with macros
Adding back tests for scripter
* flake8 nonsense
- Added DataType support in both OE and Scripting.
- Added unit tests in test_scripting.py. These do some basic template validation - we should go back and add more for the other object types. This actually validates navigating the PGSMO Database and Schema to get the object in addition to template generation. They also do some basic verification of the output.
- Added Sequence and Collation support to OE as this was missed. We need tests for these but don't seem to have a pattern. Created Microsoft/carbon#1716 to track this.