Skip to content

MSSQL "quote identifiers" setting is not being applied for foreign keys #1144

Closed
@simonachmueller

Description

@simonachmueller
  • pgloader --version

    3.6.38a62a7
    
  • did you test a fresh compile from the source tree?

    Yes, it's build from sources

  • did you search for other similar issues?

  • how can I reproduce the bug?

    Create database and tables with following script:

CREATE DATABASE [smmigtest2]
GO

USE [smmigtest2]
GO


CREATE TABLE [dbo].[Parent](
	[Id] [uniqueidentifier] NOT NULL,
	[Name] [nvarchar](50) NULL,
 CONSTRAINT [PK_Parent] PRIMARY KEY CLUSTERED 
 (
	[Id] ASC
 )
) ON [PRIMARY]
GO



CREATE TABLE [dbo].[Child](
	[Id] [uniqueidentifier] NOT NULL,
	[Value] [int] NULL,
	[ParentId] [uniqueidentifier] NULL,
 CONSTRAINT [PK_Child] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[Child]  WITH CHECK ADD  CONSTRAINT [FK_Child_Parent] FOREIGN KEY([Id])
REFERENCES [dbo].[Parent] ([Id])
GO

ALTER TABLE [dbo].[Child] CHECK CONSTRAINT [FK_Child_Parent]
GO

Keep in mind the casing of the foreign key FK_Child_Parent.

Then run pgloader as /build/bin/pgloader --no-ssl-cert-verification -v -d ../../pgloaderstring

load database

    from mssql://USERNAME:PASSWORD@HOST/DATABASE
    into postgresql://USERNAME:PASSWORD@HOST/DATABASE?sslmode=prefer

cast type datetimeoffset to timestamptz
cast type datetime2 to timestamptz
cast type uniqueidentifier to uuid using sql-server-uniqueidentifier-to-uuid

with prefetch rows=5000, batch rows=1000, quote identifiers, create indexes, include drop, create tables

set work_mem to '16MB', maintenance_work_mem to '512 MB'

before load do $$ drop schema if exists dbo cascade; $$;

  • pgloader output you obtain
NOTICE ALTER TABLE "dbo"."Parent" ADD PRIMARY KEY USING INDEX "idx_6316906_PK_Parent";
2020-05-07T14:58:12.339000+02:00 NOTICE ALTER TABLE "dbo"."Child" ADD PRIMARY KEY USING INDEX "idx_6316903_PK_Child";
2020-05-07T14:58:12.687000+02:00 NOTICE ALTER TABLE "dbo"."Child" ADD CONSTRAINT FK_Child_Parent FOREIGN KEY("Id") REFERENCES "dbo"."Parent"("Id") ON UPDATE NO ACTION ON DELETE NO ACTION

  • data that is being loaded, if relevant

Check foreign key name casing in the postgresql:
image

  • How the data is different from what you expected, if relevant
    Is should keep casing

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions