AbstractReturns the batch separator for the database platform. SQL Server: 'GO' PostgreSQL: '' (empty string, uses semicolons)
AbstractDialectThe SQL dialect instance for this provider.
AbstractNeedsWhether this platform needs explicit view refresh after schema changes.
SQL Server: true (uses sp_refreshview)
PostgreSQL: false (views resolve at query time)
AbstractNeedsWhether this platform needs a post-sync fix for virtual field nullability.
SQL Server: false
PostgreSQL: true (PG view columns always report attnotnull=false)
AbstractPlatformThe database platform key (e.g., 'sqlserver', 'postgresql').
AbstractTimestampReturns the native timestamp-with-timezone type name for this platform.
SQL Server: DATETIMEOFFSET
PostgreSQL: TIMESTAMPTZ
AbstractaddGenerates ALTER TABLE ... ADD COLUMN SQL.
SQL Server: ALTER TABLE [schema].[table] ADD colName TYPE [NOT] NULL [DEFAULT expr]
PostgreSQL: ALTER TABLE schema."table" ADD COLUMN "colName" TYPE [NOT] NULL [DEFAULT expr]
OptionaldefaultExpression: stringAbstractaddGenerates SQL to add a default constraint/value to a column.
SQL Server: ALTER TABLE ... ADD CONSTRAINT DF_name DEFAULT expr FOR [col]
PostgreSQL: ALTER TABLE ... ALTER COLUMN "col" SET DEFAULT expr
AbstractalterGenerates ALTER TABLE ... ALTER COLUMN to change type and nullability.
SQL Server: ALTER TABLE ... ALTER COLUMN col TYPE NULL|NOT NULL
PostgreSQL: ALTER TABLE ... ALTER COLUMN "col" TYPE type, ALTER COLUMN "col" SET|DROP NOT NULL
ProtectedbuildBuilds the EXEC parameter fragment(s) for a single field when calling a
tolerant update SP. Returns an array of @ParamName = value strings.
For most fields this is just ['@FieldName = @variable']. But when
clearValue is true and the field has a _Clear companion (see
needsClearCompanion), an additional @FieldName_Clear = 1 is
prepended so the tolerant SP actually sets the column to NULL instead
of treating the NULL parameter as "leave unchanged".
This is the single source of truth for the calling convention of tolerant update SPs. All codepaths that generate EXEC calls to spUpdate — cascade-update cursors, future SP-to-SP calls, etc. — should use this method to stay in sync with the SP declaration logic in generateCRUDParamString.
The entity field being passed
The SQL expression for the value (e.g. @prefixed_var)
Whether this field is being explicitly set to NULL
AbstractbuildBuilds primary key variable declarations, select fields, fetch-into, and SP param strings for use in cursor-based cascade operations.
Optionalprefix: stringAbstractcallGenerates SQL to invoke a stored procedure or function.
SQL Server: EXEC [schema].[spName] @Param1='val1', @Param2='val2'
PostgreSQL: SELECT * FROM schema."spName"('val1', 'val2')
The schema containing the routine.
The routine name (e.g., spUpdateExistingEntitiesFromSchema).
Ordered array of parameter values as pre-formatted SQL strings.
For SQL Server these become @ParamName='value' pairs;
for PostgreSQL they become positional arguments.
OptionalparamNames: string[]Optional parameter names for SQL Server's @Name=value syntax.
Ignored on PostgreSQL.
Whether this dialect can handle a base view that LEFT-JOINs itself to read
a virtual computed column (e.g. vwRecordChanges joining to itself for the
RestoredFromID virtual NameField lookup).
Default: false. No shipped provider currently supports this pattern:
CREATE OR REPLACE VIEW resolves view names against catalog
state at parse time, so a self-reference fails with 42P01 undefined_table. A CREATE OR REPLACE retry against a NULL-typed stub
then fails with cannot change data type of view column ... from text to character varying(N) because PG enforces strict column-type compat.DROP VIEW then CREATE VIEW,
and SQL Server resolves view-body references at parse/bind time — there
is no deferred name resolution for view bodies the way there is for
stored procedures. After the DROP, the post-DROP self-reference fails
with error 208 "Invalid object name".With the default of false, sql_codegen.ts skips the self-virtual-
NameField join entirely for self-FK + virtual-NameField cases. The trade-
off: the corresponding virtual lookup column (e.g. RestoredFrom on
vwRecordChanges, or Parent on a vwTags-style view if the Name Field
were computed) is not emitted on the base view. Matches the baseline-
shipped view shapes.
Subclasses can override to return true if a future dialect (or a
provider that switches to a different emit pattern, e.g. stub-then-alter)
can support the self-reference. The fix for the underlying conflation
between SQL Server computed columns and view-only columns under
IsVirtual = 1 would let the join target the base table instead,
removing the need for this capability flag entirely.
Protected AbstractcolumnThe column portion of an automatic FK index name, in this dialect's spelling.
AbstractcompareCompares two data type names, accounting for platform-specific aliases.
For example, PostgreSQL reports timestamp with time zone in information_schema
but DDL uses timestamptz.
The type name as reported by the database catalog.
The expected type name (from DDL or configuration).
True if the types are equivalent.
AbstractconditionalGenerates a conditional INSERT statement (insert only if not exists).
SQL Server: IF NOT EXISTS (checkQuery) BEGIN insertSQL END
PostgreSQL: DO $$ BEGIN IF NOT EXISTS (checkQuery) THEN insertSQL; END IF; END $$
The SELECT query to check for existence.
The INSERT statement to execute if the check returns no rows.
AbstractdropGenerates SQL to drop an existing default constraint from a column. SQL Server: Dynamic lookup of constraint name from sys catalog + DROP. PostgreSQL: Dynamic lookup from pg_catalog + ALTER COLUMN DROP DEFAULT.
AbstractdropGenerates a DROP statement for a database object (view/procedure/function).
SQL Server: IF OBJECT_ID('...', 'P') IS NOT NULL DROP PROCEDURE ...
PostgreSQL: DROP FUNCTION IF EXISTS ... CASCADE
Note: This differs from generateDropGuard() which is used for CREATE OR REPLACE
patterns. This method is used for cleanup operations.
OptionalexecuteOptional — dialect-specific phased execution of a single entity's full CodeGen SQL package (view, CRUD functions, permissions) for the main per-entity run path.
Default path concatenates all the SQL and hands it to the shell executor, which runs it as a single multi-statement query. When any statement fails, pg's simple-query protocol aborts the rest of the batch — so a view that fails 42P16 silently blocks the CREATE FUNCTIONs that follow for the same entity.
Providers that implement this method run the pieces in separate phases so a failure in phase 1 prevents phase 2 from producing functions that reference a missing or stale view. PG's implementation additionally routes the view phase through the 42P16 capture/restore fallback.
Phasing contract:
Phase 0 = TVF DDL (tvfSQL) — root-ID functions for recursive FKs that
the base view references. Must run before phase 1 or PG
rejects the view with function does not exist.
Phase 1 = view DDL (viewSQL) — may invoke provider-specific recovery.
Phase 2 = CRUD function DDL — ONLY runs if phase 1 succeeded.
Phase 3 = view permissions (viewPermSQL) — runs only if phase 2 succeeded.
The success/phase pair in the result identifies exactly where things
fell over so the caller doesn't have to bisect.
Root-ID TVF DDL emitted ahead of the view. Empty when the entity has no recursive ParentID FKs.
OptionalwillRegenerate?: Set<string>AbstractexecuteExecutes a SQL file using the platform's native CLI tool (sqlcmd/psql). The implementation is responsible for reading connection configuration from the environment or config objects.
Path to the SQL file to execute.
True if execution succeeded, false otherwise.
ProtectedforeignComposes the automatic foreign-key index name and enforces the dialect's identifier
length limit. Dialect-independent in shape — {prefix}{table}_{column} — while the
casing of the prefix, the table/column token spelling, and the length cap come from
the dialect hooks.
NOTE: the resulting names are deliberately NOT unified across dialects. SQL Server
names from BaseTableCodeName/CodeName, PostgreSQL from snake-cased
BaseTable/Name. Changing either would orphan every existing index in deployed
databases (CodeGen would create new ones alongside the old), so the token hooks
preserve each dialect's historical spelling exactly.
AbstractformatFormats a default value for use in generated SQL. Handles SQL functions (GETUTCDATE, gen_random_uuid, etc.) and literal values.
Protected AbstractformatRenders one complete index statement for the dialect — quoting, and the
"create only if absent" idempotency form (SQL Server wraps a sys.indexes check
around a bare CREATE INDEX; PostgreSQL uses CREATE INDEX IF NOT EXISTS).
The index NAME is supplied pre-composed and pre-truncated; implementations must use it verbatim. The indexed COLUMN, by contrast, is referenced from the field's real column name — which is not necessarily the token used to build the name.
ProtectedformatRender hook: returns the default value for a field formatted for
embedding in a generated INSERT statement. The base implementation
delegates to formatDefaultValue (which handles SQL functions, quoted
literals, etc.). Dialects with type-strict semantics may need to
massage the value further — for example, PostgreSQL maps SQL Server
BIT literal defaults (0/1) to PG BOOLEAN literals
(FALSE/TRUE) so that COALESCE(boolean_param, 0) doesn't fail
with a type-mismatch error.
AbstractgenerateGenerates a comment header for the combined all-entities SQL file.
AbstractgenerateGenerates the complete base view DDL for an entity, including the DROP guard. The orchestrator provides pre-computed context (related fields, joins, parent joins, etc.) so the provider only needs to assemble the platform-specific SQL.
AbstractgenerateGenerates the CREATE stored procedure or function for an entity.
SQL Server: CREATE PROCEDURE [schema].[spCreate...]
PostgreSQL: CREATE OR REPLACE FUNCTION schema.fn_create_...()
AbstractgenerateGenerates the DELETE stored procedure or function for an entity. Handles both hard and soft delete types, and includes cascade delete logic.
Generates the parameter list string for a CRUD routine with tolerant SP signatures (Pillar 1 of the cross-app migration architecture).
Structural logic — what's required, what's optional, when a _Clear
companion appears — lives here in the base class and is shared across
dialects. The dialect-specific syntax (parameter prefix, default
keyword, type rendering) is delegated to:
Dialect.ParameterRef(name) — @Name vs. p_nameDialect.ParameterDefault(value) — = NULL vs. DEFAULT NULLDialect.NullLiteral — NULL literalrenderParameterType(ef) — type formatting (T-SQL native vs. PG-mapped)Subclasses can override the hooks above without re-implementing the full method. Subclasses can also override the method itself if their dialect imposes additional constraints not modelable through hooks (e.g. PostgreSQL's "all params after the first DEFAULT must also have DEFAULTs" rule, which the PostgreSQL provider handles via override).
AbstractgenerateGenerates GRANT EXECUTE permission for a CRUD routine.
AbstractgenerateGenerates the UPDATE stored procedure or function for an entity. Includes the updated-at trigger generation.
AbstractgenerateGenerates a conditional DROP + CREATE guard for a database object.
For SQL Server: IF OBJECT_ID(...) IS NOT NULL DROP ...
For PostgreSQL: DROP ... IF EXISTS ... or CREATE OR REPLACE ...
Generates CREATE INDEX statements for all foreign key columns on an entity. Returns an array of individual index DDL strings.
This is a template method: every dialect-INDEPENDENT decision (which fields qualify as indexable foreign keys, and how the index name is composed and truncated) lives here so it cannot drift between providers. Dialects supply only the genuinely different pieces via formatIndexStatement, tableToken, columnToken, indexPrefix, and maxIdentifierLength.
Previously this was abstract, so each provider reimplemented the whole thing and
they drifted in a way that was not dialect-specific — SQL Server omitted the
primary-key/virtual-field exclusions that PostgreSQL had. See
isIndexableForeignKey.
AbstractgenerateGenerates full-text search infrastructure for an entity: SQL Server: FULLTEXT CATALOG + INDEX + inline TVF PostgreSQL: tsvector column + GIN index + trigger + search function
AbstractgenerateGenerates GRANT EXECUTE permission for a full-text search function.
Generates the column-list or value-list portion of an INSERT
statement, depending on whether prefix is empty (column names)
or non-empty (parameter values).
Empty prefix — produces dialect-quoted column names suitable
for the INSERT INTO ... (col1, col2) clause.
Non-empty prefix — produces the parameter-value list suitable
for the VALUES (...) clause, with tolerant-SP behavior:
CurrentTimestampUTC() (created/updated) or NullLiteral
(deleted-at).CASE that detects
the empty-GUID sentinel and falls back to the database default;
otherwise wraps with IsNull.IsNull(@Param, default)._Clear
companion CASE so callers can distinguish "leave default"
from "explicitly NULL."Skips auto-increment, virtual, and non-updatable fields. The PK
column can be optionally excluded (used by the two-branch GUID-PK
insert pattern in generateCRUDCreate).
Dialect-specific syntax is fully delegated to:
Dialect.QuoteIdentifier, Dialect.ParameterRef,Dialect.IsNull, Dialect.NullLiteral,Dialect.CurrentTimestampUTC, Dialect.EmptyUUIDLiteral,formatInsertDefaultValue(ef) render hook (for type-strict
dialects that need to massage default values).AbstractgenerateGenerates the JOIN clause for a root ID function in a base view.
SQL Server: OUTER APPLY [schema].[fnTable_GetRootID](t.ID) AS rootFn
PostgreSQL: LEFT JOIN LATERAL schema.fn_table_get_root_id(t."ID") AS root_fn ON true
AbstractgenerateGenerates the SELECT expression for a root ID field in a base view.
SQL Server: rootFn.RootID AS [FieldRoot...]
PostgreSQL: root_fn.root_id AS "FieldRoot..."
AbstractgenerateGenerates a recursive root-ID function for a self-referencing FK field. SQL Server: inline TVF with recursive CTE + OUTER APPLY in view. PostgreSQL: scalar function with recursive CTE + LEFT JOIN LATERAL in view.
AbstractgenerateGenerates the cascade delete/update SQL for a single related entity. Called by the orchestrator for each FK relationship when CascadeDeletes is true.
AbstractgenerateGenerates a comment header for a generated SQL file.
AbstractgenerateGenerates ALTER TABLE statements to add __mj_CreatedAt and __mj_UpdatedAt columns.
AbstractgenerateGenerates the __mj_UpdatedAt timestamp trigger for an entity. SQL Server: single AFTER UPDATE trigger. PostgreSQL: companion function + BEFORE UPDATE trigger.
Generates the SET clause body for an UPDATE statement with tolerant
merge semantics. Each non-PK column wraps the parameter with the
dialect's null-coalescing call against the column's existing value
(SET [Col] = ISNULL(@Param, [Col]) on SQL Server,
SET "col" = COALESCE(p_col, "col") on PostgreSQL) so omitting a
parameter preserves the existing row value. Nullable columns whose
database default is non-NULL also emit a _Clear companion branch
that lets callers distinguish "leave unchanged" from "explicitly NULL."
The full structural logic lives here in the base class; only the
per-line render is dialect-specific and that's resolved through the
Dialect accessor's helpers (QuoteIdentifier, ParameterRef,
IsNull, NullLiteral). Subclasses can override to customize line
formatting if a future dialect needs something different.
AbstractgenerateAbstractgenerateGenerates SQL to refresh/recompile a view.
SQL Server: EXEC sp_refreshview 'schema.viewName';
PostgreSQL: returns empty string (no-op).
AbstractgenerateGenerates a simple test query to validate a view is functional.
SQL Server: SELECT TOP 1 * FROM [schema].[viewName]
PostgreSQL: SELECT * FROM "schema"."viewName" LIMIT 1
AbstractgetReturns an additional WHERE clause fragment for the check-constraints query.
SQL Server: WHERE SchemaName NOT IN (...) when excludeSchemas is provided.
PostgreSQL: empty string (the PG view already handles schema filtering).
AbstractgetReturns a SQL query string to check if a given column is part of a composite unique constraint. The query should accept the schema, table, and column name as parameters (platform-specific).
The orchestrator checks result.recordset.length > 0 to determine if the column
participates in a multi-column unique index.
Note: Implementations should return the SQL query string. The orchestrator is responsible for executing the query with proper parameterization for the target database platform.
AbstractgetReturns the name of the CRUD routine for an entity.
SQL Server: spCreateEntityName
PostgreSQL: fn_create_entity_name
AbstractgetReturns an additional WHERE clause fragment for the missing-base-tables query.
SQL Server: WHERE VirtualEntity=0
PostgreSQL: empty string (PG query doesn't need this filter).
AbstractgetGenerates SQL to fix virtual field nullability after metadata sync. PostgreSQL: Updates AllowsNull for virtual fields based on the FK column's nullability. SQL Server: returns empty string (no fix needed).
The MJ core schema name.
AbstractgetReturns a SQL query string to check if a foreign key index already exists.
Used by the orchestrator to conditionally create FK indexes.
SQL Server: queries sys.indexes with OBJECT_ID
PostgreSQL: queries pg_indexes
The result set should return rows if the index exists (length > 0 means exists).
Returns DDL that creates/replaces the platform's metadata-management
support objects (introspection views and the routines manage-metadata
invokes via callRoutineSQL), or null when the platform ships
them through migrations instead.
These objects are CodeGen's own machinery — only CodeGen calls them — so platforms that return DDL here get it executed (idempotently) at the start of every manageMetadata run. That guarantees the objects can never be missing or version-skewed relative to the CodeGenLib code that calls them.
SQL Server: returns null (objects ship in the baseline migrations).
PostgreSQL: returns the full support-object DDL.
AbstractgetGenerates the SQL to retrieve pending entity fields that exist in the database but not yet in the MJ metadata. This is a large, platform-specific query.
The MJ core schema name (e.g., __mj).
OptionalentityIDs: string[]Optional list of entity UUIDs to scope the query to. When provided,
the query filters to fields belonging to those entities only — used by Pass 2 to
avoid re-scanning the entire schema for entities that haven't changed. undefined
or empty preserves the prior unscoped behavior.
AbstractgetReturns a SQL query string to retrieve the primary key index name for a table.
SQL Server: queries sys.indexes + sys.key_constraints
PostgreSQL: queries pg_index + pg_class
The result set must include a column named IndexName.
Returns a SQL query that lists every stored procedure / function name in the given schemas. Used by the post-run CRUD validator to diff expected vs actual routine presence in one round trip.
The result set must contain exactly two columns:
schema_name — the schema the routine lives in
routine_name — the proc/function name as stored in the catalog
SQL Server: queries sys.objects for procedures and functions.
PostgreSQL: queries pg_proc joined to pg_namespace.
Default: returns empty string. Providers that don't implement this opt out of the post-run CRUD validator (the validator returns no missing when this returns empty), preserving backwards compatibility for downstream subclasses that haven't been updated.
AbstractgetReturns an array of system schema names that should be excluded from
metadata synchronization. Empty array if the platform has no system
schemas that need excluding.
SQL Server: [] (no system schemas need excluding)
PostgreSQL: ['information_schema', 'pg_catalog', 'pg_toast', ...]
AbstractgetReturns SQL to get column metadata for a view or table. Result columns: FieldName, Type, Length, Precision, Scale, AllowsNull.
AbstractgetReturns a SQL query string to retrieve the current view definition from the database.
SQL Server: SELECT OBJECT_DEFINITION(OBJECT_ID('[schema].[viewName]')) AS ViewDefinition
PostgreSQL: SELECT pg_get_viewdef('"schema"."viewName"'::regclass, true) AS "ViewDefinition"
The result set must include a column named ViewDefinition.
AbstractgetReturns SQL to check if a view exists.
The query uses @ViewName and @SchemaName as named parameters.
Returns 1 row if the view exists.
ProtectedindexPrefix for automatic FK index names. Dialects override to match their casing convention.
ProtectedisDecides whether a field should get an automatic foreign-key index. Dialect-independent.
A field qualifies when it points at another entity and is a real, materialized column:
RelatedEntityID — the field is a foreign key. This is the base-table column that
actually stores the relationship. (The sibling RelatedEntity field is a view join
on that ID, not a base column; the two never disagree in practice — verified 0/793
divergence across the FK fields in the reference database — so keying off the ID is
both equivalent and more direct.)!IsPrimaryKey — a primary key is already covered by its own index. In 1:1
extension-table patterns the child's PK is also an FK to the parent, and indexing it
again would be pure overhead.!IsVirtual — virtual fields have no underlying column, so CREATE INDEX on one
would reference a column that does not exist.The PK/virtual exclusions previously existed only on the PostgreSQL side; hoisting them here applies them to every dialect by construction. Current real-world exposure is zero (no FK field in the reference database is also a primary key or virtual), so this is a guard against a future case rather than a change in today's generated output.
ProtectedisTolerant-SP semantics: returns true when this parameter must be provided by every caller (no default, no fallback). Pure decision logic — Pillar 1 of the cross-app migration architecture.
ProtectedmaxMaximum identifier length for this dialect; FK index names are truncated to it.
ProtectedneedsReturns true when codegen should emit a <Param>_Clear companion
parameter for the given field. The companion lets callers
disambiguate "leave unchanged / apply DB default" (omit the
parameter) from "explicitly set this column to NULL"
(<Param>_Clear = 1). Required only for nullable columns whose
database default is itself non-NULL — without the companion, a
caller could not preserve a literal NULL because the dialect's
IsNull wrap would always substitute the default.
Routes the NULL-literal check through the dialect so future dialects can override what "this value is NULL" looks like in their generated SQL. Pure decision logic — no rendering.
AbstractparseParses a raw default-value string from the database catalog into a clean value.
SQL Server: strips wrapping parens and N'' prefix, e.g. (getdate()) → getdate()
PostgreSQL: strips ::type casts, recognizes nextval() as auto-increment (returns null).
The cleaned default value, or null if the column has no meaningful default.
AbstractquoteQuotes mixed-case identifiers in a raw SQL string for execution. SQL Server: returns the SQL unchanged (case-insensitive identifiers). PostgreSQL: double-quotes PascalCase identifiers to preserve case.
OptionalregenerateOptional — dialect-specific fast path for regenerating a single entity's base view with recovery logic.
When provided, the orchestration layer (sql.ts regenerateFailedBaseViews)
will route regeneration through this method instead of the generic
write-temp-file-and-shell-out path. Implementations can add capture/
recovery behavior around the CREATE OR REPLACE VIEW — e.g. PG's 42P16
capture-and-restore fallback that preserves dependent views, functions,
grants, comments, and ownership across the unavoidable DROP CASCADE.
The entity whose base view is being regenerated.
The full output of generateBaseView for this entity.
OptionalwillRegenerate: Set<string>Optional set of "schema.viewName" strings for
views the caller will regenerate later in the same
run — implementations may skip restoring those
dependents since CodeGen will recreate them.
ProtectedrenderRender hook: returns the SQL type token that should appear in a CRUD
parameter declaration for the given field. SQL Server emits the
entity-field's SQLFullType directly (T-SQL native); PostgreSQL maps
it through its type mapper. Override per dialect if your generated
SP signatures need a transformed type.
AbstractSetupSet up the per-platform data source for a CodeGen run: open a connection pool, configure the metadata provider, build the CodeGenConnection, and resolve the audit user.
Where this lives and why — the orchestrator (RunCodeGenBase)
used to switch on configInfo.dbPlatform inline and call private
setupSQLServerDataSource() / setupPostgreSQLDataSource() methods.
That bypassed the existing factory pattern (see e.g.
manage-metadata.ts's get dbProvider(), which dispatches via
MJGlobal.Instance.ClassFactory.CreateInstance(CodeGenDatabaseProvider, platform))
and meant adding a third platform would require touching the
orchestrator. Moving the setup here puts it behind the same
factory: subclasses register via @RegisterClass(CodeGenDatabaseProvider, '<platform>')
and the orchestrator just resolves + calls.
Subclasses are responsible for:
MSSQLConnection() / PGConnection() so multiple setupDataSource()
calls reuse the same pool)SetProvider(...)
when appropriateUserCache,
PostgreSQL hand-queries vwUsers/vwUserRoles — see implementations
for the deliberate asymmetry note)status_logging helpers when desiredProtectedshouldDelegates to EntityFieldInfo.IsSPParameter — the single source
of truth for whether a field appears as a parameter in spCreate /
spUpdate. Runtime data providers consume the same predicate so the
SP signature emitted here and the EXEC argument list built at save
time always agree.
Protected AbstracttableThe table portion of an automatic FK index name, in this dialect's spelling.
Cross-checks the entity-level AllowAPI/spGenerated/sp* configuration against the routines actually present in the database after CodeGen finishes. Returns one entry per missing routine.
Why this exists: silent generation gaps (e.g. an entity dropped because an upstream batch errored, or stale entity-field metadata causing the PK check to fail) historically reported success at the pipeline level while leaving runtime CRUD broken. This validator turns that into a loud, actionable failure list before the install pipeline exits.
What's expected per entity:
Allow{Type}API flag is false.getCRUDRoutineName (which honors
entity.spCreate/spUpdate/spDelete overrides; otherwise returns
the dialect-generated default).Schema-level case sensitivity: SQL Server is case-insensitive, PostgreSQL is case-preserving. Both lookups normalize via lowercase to keep the validator dialect-agnostic.
Default implementation works for both dialects via the
getRoutineNamesBySchemaSQL helper. Providers may override to add
platform-specific shortcuts (e.g. checking only sys.procedures on
SQL Server) but the default is fine for all current dialects.
AbstractwrapWraps an INSERT statement with a conditional existence check at the statement level.
SQL Server: Adds IF NOT EXISTS (...) BEGIN prefix and END suffix.
PostgreSQL: Adds ON CONFLICT DO NOTHING suffix (no prefix needed).
The SQL Server existence check query. Ignored on PostgreSQL.
An object with prefix and suffix strings to wrap around the INSERT.
Abstract base class for database-specific code generation providers.
Each database platform (SQL Server, PostgreSQL, etc.) implements this class to generate the appropriate DDL for views, CRUD routines, triggers, indexes, full-text search, permissions, and other database objects.
The orchestrator (SQLCodeGenBase) calls these methods to produce platform-specific SQL while keeping the high-level generation logic database-agnostic.