Skip to content

mssql: Incorrect syntax with table_ddl and primary table_keys #694

@guaripete-github

Description

@guaripete-github

Sling version:

1.5.4

What is the Operating System?

Windows

Do you have a CLI Pro/Platform subscription?

No

Description of the issue

Adding primary keys when using table_ddl or sqlserver.yml template that include table options (e.g., data_compression) yields incorrect DDL.

create table "schema"."table" (
  "col1" nvarchar(10),
  "col2" nvarchar(6)
) with (data_compression=page, primary key ("col1", "col2"))

should generate

create table "schema"."table" (
  "col1" nvarchar(10),
  "col2" nvarchar(6),
   primary key ("col1", "col2")
) with (data_compression=page)

Replication Configuration

  target_options:
    table_ddl:
      CREATE TABLE {object_name} ({col_types}) WITH (DATA_COMPRESSION = PAGE)

streams:
  schema.table:
    primary_key: [col1, col2]
    target_options:
      table_keys:
        primary: [col1, col2]

Log Output

~ Error executing: create table "schema"."table" ("col1" nvarchar(10),
  "col2" nvarchar(6)) with (data_compression=page, primary key ("col1", "col2"))
--- transaction.go:139 ExecContext ---
--- transaction.go:139 ExecContext ---
mssql: Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions