Skip to content

SQL Server to Postgres Migration Fixes#7468

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

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

Conversation

@labkey-martyp
Copy link
Copy Markdown
Contributor

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

Rationale

  1. age_in_days / age(..., SQL_TSI_DAY) — Preserves SQL Server's calendar-boundary semantics for timestampdiff(SQL_TSI_DAY, ...) on Postgres, where the native operator counts 24-hour intervals instead. Consistent with the existing age_in_months/age_in_years functions; permanent addition to LabKey SQL.
  2. CAST(... AS BOOLEAN) in SELECT lists (QuerySelect.java) — On SQL Server, boolean QMethodCalls in a select list are wrapped in CASE WHEN (...) THEN 1 ELSE 0 END to avoid predicates as scalar values. But CAST(x AS BIT) is already a value, not a predicate, and SQL Server rejects the wrapped form. Fix excludes ConvertInfo from the wrap. (repro: insert failing query / error)
  3. DatabaseMigrationService.registerSchemaContributor — Interface for DatabaseMigrationService.registerSchemaContributor in premiumModules

Related Pull Requests

Changes

  • Method.java — age_in_days method, age(..., SQL_TSI_DAY) dispatch, updated validation
  • QueryTestCase.jsp — tests for both new syntaxes including datetime calendar-boundary cases
  • LabKeySql.md — documents age_in_days
  • QuerySelect.java — skip boolean wrap for CAST/CONVERT on SQL Server
  • DatabaseMigrationService.java — new registerSchemaContributor interface method

@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