Migrate remaining ONPRC modules' SQL scripts to PostgreSQL - #1859
Open
labkey-adam wants to merge 11 commits into
Open
Migrate remaining ONPRC modules' SQL scripts to PostgreSQL#1859labkey-adam wants to merge 11 commits into
labkey-adam wants to merge 11 commits into
Conversation
Contributor
Author
|
@ankurjuneja @labkey-martyp note the TODO in |
ankurjuneja
previously approved these changes
Aug 24, 2026
The ExtScheduler overlap trigger carried the T-SQL spelling `PropertySets."Set"` into PostgreSQL, where the column is declared unquoted and therefore folds to lowercase `set`. Quoted identifiers are matched exactly, so the join referenced a column that does not exist. plpgsql does not plan a function body until first execution, so the install succeeded and every subsequent insert or update of an extscheduler.events row would have failed. `p_SciShieldToPrimeProcess` and `p_ComplianceTranslatestringUpdate` relied on SQL Server's case-insensitive default collation. The SciShield import lowercases the employee id before matching, which found nothing on PostgreSQL and silently marked every incoming record as an invalid employee id; the lookups now compare with `lower()` on both sides and the insert writes the spelling stored in ehr_compliancedb.employees so the completiondates foreign key resolves. The "arrs" to "DCM" rename now uses `ILIKE` and `regexp_replace(..., 'gi')` so it reaches values that are not already lowercase. Container EntityIds are a native `uniqueidentifier` on SQL Server but a `VARCHAR(36)` domain on PostgreSQL, and LabKey generates them in lowercase, so the hardcoded uppercase GUID literals matched nothing and wrote rows into a container that resolves to no folder. Lowercased in the PostgreSQL scripts only; the SQL Server scripts are correct as written.
…dures The two report procedures join ehr_compliancedb.employeeperunit to ehr_compliancedb.requirementspercategory on `unit` or `category`. requirementspercategory constrains both columns with foreign keys to unit_names and employeecategory, but employeeperunit has no constraints at all, so its values are uncontrolled free text. SQL Server's case-insensitive collation absorbed any drift; on PostgreSQL a `DCM` against a `dcm` silently drops the employee from the compliance report rather than raising anything. Applied to all six joins in each of the bootstrap and 25.000-25.001 scripts. NULL behavior is unchanged: employeeperunit.unit and .category are nullable, and `lower(NULL) = lower(NULL)` is NULL just as `NULL = NULL` was.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Rationale
Consolidate and migrate SQL upgrade scripts in the last three ONPRC modules:
Tasks