Skip to content

SQL Server to Postgres Migration Fixes#7468

Open
labkey-martyp wants to merge 7 commits intodevelopfrom
fb_query_validation
Open

SQL Server to Postgres Migration Fixes#7468
labkey-martyp wants to merge 7 commits intodevelopfrom
fb_query_validation

Conversation

@labkey-martyp
Copy link
Contributor

@labkey-martyp labkey-martyp commented Mar 3, 2026

Rationale

  1. Found this during sql server -> pg migration. This is throwing an error when trying to hard code a boolean value as NULL in LK sql. This is done across some unions where NULL is essentially a third state. PG requires a cast, but casting the value when using sql server throws an error in this attempted conversion since it does not produce a valid predicate for this case statement. This fix just opts out of this case statement if the value is.
  2. PG JDBC timestampdiff function, which we use for most of our LK SQL timestampdiff intervals, has bugs with parameter swapping. This adds timestampdiff2 which doesn't use the PG JDBC timestampdiff at all, and implements the missing intervals.

Changes

  • Update conditional to not do this case statement if the method call is Method.ConvertInfo.
  • New timestampdiff2 function. Ensuring all values are truncated to only return whole intervals completed.
  • Pass through to standard timestampdiff for all non-PG dialects.
  • Test cases for timestampdiff2.

@labkey-martyp labkey-martyp changed the title NULL boolean fix SQL Server to Postgres Migration Fixes Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants