-
Notifications
You must be signed in to change notification settings - Fork 9
Remove SQL Server upgrade scripts and code #3168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
labkey-jeckels
wants to merge
1
commit into
develop
Choose a base branch
from
fb_removeSqlServer
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| Name: ETLtest | ||
| SchemaVersion: 26.001 | ||
| SupportedDatabases: mssql, pgsql | ||
| ManageVersion: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # External SQL Server fixtures | ||
|
|
||
| SQL Server is no longer supported as LabKey's primary database, but it **is** still supported as an external data source, including running stored procedures through the DataIntegration `StoredProcedureStep`. These scripts are the SQL Server dialect fixtures for that feature, preserved when the primary-DB SQL Server dbscripts were removed. | ||
|
|
||
| They are deliberately **not** under `schemas/dbscripts/`. The module upgrade scanner only reads `schemas/dbscripts/<dialect>/`, so nothing here can ever execute against the primary database. Apply them by hand to an external SQL Server database. | ||
|
|
||
| | Script | Contents | | ||
| |---|---| | ||
| | `sqlserver/etltest-procs.sql` | `etltest` schema, the `source` table, and the `etlTest` / `etlTestResultSet` procedures covering the nine test modes (return codes, raised errors, in/out parameter persistence, run and modified-since filter strategies, result sets) | | ||
| | `sqlserver/etltest-specialchars.sql` | `"etl test!schema"."etl""test proc!"` — identifier quoting/escaping for schema and procedure names containing spaces, `!`, and an embedded double-quote. Driven by `../ETLs/SProcSpecialCharacters.xml` | | ||
|
|
||
| ## Porting notes | ||
|
|
||
| These were lifted from the deleted `schemas/dbscripts/sqlserver/` scripts and adjusted for a database that is not a LabKey primary DB: | ||
|
|
||
| - `entityid` is a LabKey alias type defined by `core`; replaced with `UNIQUEIDENTIFIER`. | ||
| - The `container` foreign key to `core.containers` was dropped — that table does not exist in an external database. | ||
| - `EXEC core.fn_dropifexists` calls were dropped for the same reason. Scripts assume a clean schema. | ||
| - The procedures are the final state, not the `CREATE` plus `ALTER` chain the versioned dbscripts carried. | ||
|
|
||
| The trap worth knowing before editing `etltest-specialchars.sql`: LabKey's `SqlScanner` does not understand `[bracket]` quoting and will misread a double-quote inside brackets as the start of a string literal. Use `"..."` with the interior quote doubled as `""`, and keep `SET QUOTED_IDENTIFIER ON`. | ||
|
|
||
| ## Not wired up in TeamCity | ||
|
|
||
| There is no automated coverage for this path yet, and `test.properties.template` has no external-datasource keys at all — that absence, not a missing fixture, is the gap. Wiring it up needs, at minimum: | ||
|
|
||
| - external SQL Server datasource properties in `test.properties.template` and the TeamCity build configuration | ||
| - a way to apply these scripts to that database during test setup | ||
| - a skip gate for "an external SQL Server datasource is configured". Note this is **not** `SqlserverOnlyTest`, which means "the primary database is SQL Server" and is now permanently false. |
203 changes: 203 additions & 0 deletions
203
modules/ETLtest/resources/externalFixtures/sqlserver/etltest-procs.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,203 @@ | ||
| /* | ||
| * Copyright (c) 2026 LabKey Corporation | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| -- SQL Server fixture for the DataIntegration StoredProcedureStep. Apply by hand to an external SQL Server | ||
| -- database; see ../README.md. Not a module dbscript: it is deliberately outside schemas/dbscripts/ so the | ||
| -- module upgrade scanner never runs it against the primary database. | ||
|
|
||
| -- entityid is a LabKey alias type defined by core, and core.containers does not exist in an external | ||
| -- database, so container is a bare UNIQUEIDENTIFIER here with no foreign key. The primary-DB Postgres | ||
| -- script keeps both. | ||
| CREATE SCHEMA etltest; | ||
| GO | ||
|
|
||
| CREATE TABLE etltest.source( | ||
| RowId INT IDENTITY(1,1), | ||
| container UNIQUEIDENTIFIER, | ||
| created DATETIME, | ||
| modified DATETIME, | ||
| id VARCHAR(9), | ||
| name VARCHAR(100), | ||
| TransformRun INT, | ||
| rowversion rowversion, | ||
|
|
||
| CONSTRAINT PK_etlsource PRIMARY KEY (rowid), | ||
| CONSTRAINT AK_etlsource UNIQUE (container,id) | ||
| ); | ||
| GO | ||
|
|
||
| CREATE PROCEDURE etltest.etlTest | ||
| @transformRunId int, | ||
| @containerId UNIQUEIDENTIFIER = NULL OUTPUT, | ||
| @rowsInserted int = 0 OUTPUT, | ||
| @rowsDeleted int = 0 OUTPUT, | ||
| @rowsModified int = 0 OUTPUT, | ||
| @returnMsg varchar(100) = 'default message' OUTPUT, | ||
| @debug varchar(1000) = '', | ||
| @filterRunId int = null, | ||
| @filterStartTimeStamp datetime = null OUTPUT, | ||
| @filterEndTimeStamp datetime = null OUTPUT, | ||
| @testMode int, | ||
| @testInOutParam varchar(10) = null OUTPUT, | ||
| @runCount int = 1 OUTPUT, | ||
| @previousFilterRunId int = -1 OUTPUT, | ||
| @previousFilterStartTimeStamp datetime = null OUTPUT, | ||
| @previousFilterEndTimeStamp datetime = null OUTPUT | ||
| AS | ||
| BEGIN | ||
|
|
||
| /* | ||
| Test modes | ||
| 1 normal operation | ||
| 2 return code > 0 | ||
| 3 raise error | ||
| 4 input/output parameter persistence | ||
| 5 override of persisted input/output parameter | ||
| 6 Run filter strategy, require filterRunId. Test persistence. | ||
| 7 Modified since filter strategy, no source, require filterStartTimeStamp & filterEndTimeStamp, | ||
| populated from output of previous run | ||
| 8 Modified since filter strategy with source, require filterStartTimeStamp & filterEndTimeStamp | ||
| populated from the filter strategy IncrementalStartTime & IncrementalEndTime | ||
| 9 Sleep for 2 minutes before finishing | ||
| */ | ||
|
|
||
| IF @testMode IS NULL | ||
| BEGIN | ||
| SET @returnMsg = 'No testMode set' | ||
| RETURN 1 | ||
| END | ||
|
|
||
| IF @runCount IS NULL | ||
| SET @runCount = 1; | ||
| ELSE | ||
| SET @runCount = @runCount + 1; | ||
|
|
||
| IF @testMode = 1 | ||
| BEGIN | ||
| print 'Test print statement logging' | ||
| SET @rowsInserted = 1 | ||
| SET @rowsDeleted = 2 | ||
| SET @rowsModified = 4 | ||
| SET @returnMsg = 'Test returnMsg logging' | ||
| RETURN 0 | ||
| END | ||
|
|
||
| IF @testMode = 2 RETURN 1 | ||
|
|
||
| IF @testMode = 3 | ||
| BEGIN | ||
| SET @returnMsg = 'Intentional SQL Exception From Inside Proc' | ||
| RAISERROR(@returnMsg, 11, 1) | ||
| END | ||
|
|
||
| IF @testMode = 4 AND @testInOutParam != 'after' AND @runCount > 1 | ||
| BEGIN | ||
| SET @returnMsg = 'Expected value "after" for @testInOutParam on run count = ' + convert(varchar, @runCount) + ', but was ' + @testInOutParam | ||
| RETURN 1 | ||
| END | ||
|
|
||
| IF @testMode = 5 AND @testInOutParam != 'before' AND @runCount > 1 | ||
| BEGIN | ||
| SET @returnMsg = 'Expected value "before" for @testInOutParam on run count = ' + convert(varchar, @runCount) + ', but was ' + @testInOutParam | ||
| RETURN 1 | ||
| END | ||
|
|
||
| IF @testMode = 6 | ||
| BEGIN | ||
| IF @filterRunId IS NULL | ||
| BEGIN | ||
| SET @returnMsg = 'Required @filterRunId value not supplied' | ||
| RETURN 1 | ||
| END | ||
| IF @runCount > 1 AND (@previousFilterRunId IS NULL OR @previousFilterRunId >= @filterRunId) | ||
| BEGIN | ||
| SET @returnMsg = 'Required @filterRunId was not persisted from previous run.' | ||
| RETURN 1 | ||
| END | ||
| SET @previousFilterRunId = @filterRunId | ||
| END | ||
|
|
||
| IF @testMode = 7 | ||
| BEGIN | ||
| IF @runCount > 1 AND (@filterStartTimeStamp IS NULL AND @filterEndTimeStamp IS NULL) | ||
| BEGIN | ||
| SET @returnMsg = 'Required filterStartTimeStamp or filterEndTimeStamp were not persisted from previous run.'; | ||
| RETURN 1; | ||
| END; | ||
| SET @filterStartTimeStamp = CURRENT_TIMESTAMP; | ||
| SET @filterEndTimeStamp = CURRENT_TIMESTAMP; | ||
| END; | ||
|
|
||
| IF @testMode = 8 | ||
|
|
||
| BEGIN | ||
| IF @runCount > 1 AND ((@previousFilterStartTimeStamp IS NULL AND @previousFilterEndTimeStamp IS NULL) | ||
| OR (@filterStartTimeStamp IS NULL AND @filterEndTimeStamp IS NULL)) | ||
| BEGIN | ||
| SET @returnMsg = 'Required filterStartTimeStamp or filterEndTimeStamp were not persisted from previous run.'; | ||
| RETURN 1; | ||
| END; | ||
| SET @previousFilterStartTimeStamp = coalesce(@filterStartTimeStamp, CURRENT_TIMESTAMP); | ||
| SET @previousFilterEndTimeStamp = coalesce(@filterEndTimeStamp, CURRENT_TIMESTAMP); | ||
| END; | ||
|
|
||
| IF @testMode = 9 | ||
| BEGIN | ||
| -- Sleep for 30 seconds | ||
| WAITFOR DELAY '00:00:30' | ||
| RETURN 1; | ||
| END; | ||
|
|
||
| -- set value for persistence tests | ||
| IF @testInOutParam IS NOT NULL AND @testInOutParam != '' SET @testInOutParam = 'after' | ||
|
|
||
| RETURN 0 | ||
|
|
||
| END | ||
| GO | ||
|
|
||
| -- testMode 9 returns a result set rather than only output parameters, exercising the step's result-set handling. | ||
| CREATE PROCEDURE etltest.etlTestResultSet | ||
| @transformRunId int, | ||
| @containerId varchar(100) = NULL OUTPUT, | ||
| @rowsInserted int = 0 OUTPUT, | ||
| @rowsDeleted int = 0 OUTPUT, | ||
| @rowsModified int = 0 OUTPUT, | ||
| @returnMsg varchar(100) = 'default message' OUTPUT, | ||
| @debug varchar(1000) = '', | ||
| @filterRunId int = null, | ||
| @filterStartTimeStamp datetime = null OUTPUT, | ||
| @filterEndTimeStamp datetime = null OUTPUT, | ||
| @testMode int, | ||
| @testInOutParam varchar(10) = null OUTPUT, | ||
| @runCount int = 1 OUTPUT, | ||
| @previousFilterRunId int = null OUTPUT, | ||
| @previousFilterStartTimeStamp datetime = null OUTPUT, | ||
| @previousFilterEndTimeStamp datetime = null OUTPUT | ||
| AS | ||
| BEGIN | ||
|
|
||
| IF @testMode = 9 | ||
| BEGIN | ||
| SELECT * FROM etltest.source WHERE container = @containerId | ||
| END | ||
|
|
||
| IF @testInOutParam IS NOT NULL SET @testInOutParam = 'after' | ||
|
|
||
| RETURN 0 | ||
|
|
||
| END | ||
| GO |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be able to remove this line. Then we can remove support for the "supportedDatabases" property in the product.