Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pgdiff is finding differences on case sensitive table and column names when there isn't #19

Open
PedroSolintel opened this issue Nov 28, 2017 · 4 comments

Comments

@PedroSolintel
Copy link

PedroSolintel commented Nov 28, 2017

Let's say that in DB1 I have this table:

CREATE TABLE public."Test" (
	"TestID" integer
);

And then let's say that in DB2 I have the exact same table. Pgdiff detects a difference. What's worse, it'll generate the following script:

CREATE TABLE public.Test(); and ALTER TABLE public.Test ADD COLUMN TestID integer;

Which is case insensitive and thus different than the original table. If it were to generate a script, the correct one should be:

CREATE TABLE public."Test"(); and ALTER TABLE public."Test" ADD COLUMN "TestID" integer;

@joncrlsn
Copy link
Owner

Thanks. I'll create a test to verify this and get back to you.

@joncrlsn
Copy link
Owner

joncrlsn commented Dec 1, 2017

Hi Pedro, I just created a test and it doesn't find any differences. However, you are correct that my generated code does not use quotes, which I will fix.

I'm wondering if you have some differences in your databases than mine. Is it possible your two databases have different encodings? I created the two databases for testing like this:

    CREATE DATABASE db1 WITH OWNER = u1 TEMPLATE = template0;
    CREATE DATABASE db2 WITH OWNER = u1 TEMPLATE = template0;

@PedroSolintel
Copy link
Author

Interesting. I went to check the table in both databases again and the only difference between them is their ownership. In fact, my user doesn't have the permission to view the table in DB2. I then re-executed pgdiff, but now passing the admin user in the parameters, the generated script is now the following one:

DROP TABLE public.Test();

Which is odd, because the tables are still the same. I then changed the ownership in both tables to be the exactly the same one and then re-executed pgdiff. Now it got it right and didn't detect any diffs. The problem here is that changing the owner affects the diff detection on the table itself.

@joncrlsn
Copy link
Owner

joncrlsn commented Dec 8, 2017

I'm pretty sure the reason it found a difference is that your query needs to be done by a super-user that will be able to find all table definitions regardless of owner. I can test that theory later, but this has been a really busy week for me at work and at home.

If that turns out to be true, I'll add a warning in the documentation about that.

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

No branches or pull requests

2 participants