Comments (5)
Dear @rosscoombes
Ok, string array (like int array, etc.) are already supported from pg-diff.
Maybe it could be a bug on my side not encountered before.
If i remember well in pgsql you will see curly bracket if it is a comma separated list of values, while you will see a mix of ( or ] when it is a range of values. So it seems to be correct.
If you open your database with a GUI tool able to give you back COLUMN DDL and share it here; i will do my best to reproduce and fix the issue.
from pg-diff.
Dear @rosscoombes
I tried to implement the column as you suggest to reproduce the problem, and:
- Any kind of string[], independently from original DDL like
varchar[], character varying(255)[], etc.
; land into final persisted DDL like_varchar
(standard sugar alias from PG 9.x) - I tried to give
NULL, {A,B}, {ATTR_1, ATTR_2}, {}
but in every case i don't encounter your issue - Is absolutely to avoid any kind of array as KEY FIELD for data compare, don't you have a PKEY?
I tried any form of test and i can't reproduce your issue, do you fill comfortable to share (privately) your database in order to catch the issue?
from pg-diff.
Hi Michael,
Sorry for the delay. I believe the issue is that the column is being stored as an enum but it's being interpreted as an array.
Given other similar columns work fine and I can clearly see you've handled enums in the code, I think the problem must lie in my code. Thanks for looking, I'll close it and let you know if I find something relevant for your attention.
from pg-diff.
Hi Michael,
Finally got round to figuring out the problem here, I believe it's in the interpretation of a string[] versus an enum[].
When it encounters a string array, in the function __generateSqlFormattedValue, the dataTypeCategory is "A" for array and the value correctly joins back into a string.
However, if it encounters an enum[], the dataTypeCategory is also "A" for array but the format of the value is {ITEM_1,ITEM_2} and so the join fails. In this case, you can simply return value unchanged.
There seems to be two solutions here. Either you somehow figure out that the dataTypeCategory should be an "E" and then your existing code will return the correct value.
I wasn't sure how best to do that so I went with the other option of simply checking whether the value is indeed an array before doing the join, otherwise returning the value as is. As far as I can tell, this works.
See below if you want to implement...
switch (dataTypeCategory) {
...
case "A": //ARRAY
return Array.isArray(value) ? '{${value.join()}}'
: value;
case "R": //RANGE
return '${value}'
;
case "B": //BOOL
case "E": //ENUM
case "G": //GEOMETRIC
If you want to replicate, you should just need a column with an enum array e.g. "enum_Example"[]
CREATE TYPE public."enum_Example" AS ENUM (
'ITEM_1',
'ITEM_2',
'ITEM_3'
);
CREATE TABLE public."TestTable" (
id uuid NOT NULL,
attributes public."enum_Example"[],
);
Hope that helps
from pg-diff.
Dear @rosscoombes
Of course it help a lot.
From point of view of pg, it is an array of enum values, so it will never be E and it must be A.
The point is to introduce custom types, know about its real type and parse it properly.
I will investigate asap.
from pg-diff.
Related Issues (20)
- Question: Snapshot database schema with a file? Filter for a list of tables? HOT 1
- int[] field data compare - TypeError: value.replace is not a function HOT 2
- pg_catalog.pg_proc.prokind does not exist on older versions of PostgreSQL HOT 1
- Major bug: Line Ending causes program to fail HOT 5
- Question: Rollback to a certain version on a same system HOT 1
- error: type "regrole" does not exist HOT 2
- It does not appear that the tool retrieve stored proc differences nor new or dropped one HOT 2
- Errors are printed to stdout instead of stderr HOT 3
- Feature request: some options and defaults for file handling HOT 6
- Feature request: Remove the need for the 'namespaces' field in the config HOT 3
- Redshift compatibility HOT 1
- Feature Request: Compare comments HOT 6
- Column Does not Exist HOT 8
- Options to remove IF EXISTS (and similar) statements from generated scripts HOT 5
- Schema not specified for `COMMENT ON INDEX` statements, leading to RELATION ... DOES NOT EXIST HOT 3
- Data compare doesn't detect updates of NULL values HOT 2
- Triggers not implemented? HOT 3
- Please provide sample diff output in documentation
- How to generate separate scripts for Functions only and Tables Only
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pg-diff.