fordfrog / apgdiff

Another PostgreSQL Diff Tool
http://www.apgdiff.com
MIT License
355 stars 138 forks source link

Cannot parse string: COMMENT ON COLUMN #159

Closed lben closed 5 years ago

lben commented 9 years ago

I am trying to get a diff from a schema I have and I get the next error:

Exception in thread "main" cz.startnet.utils.pgdiff.parsers.ParserException: Cannot parse string: COMMENT ON COLUMN public.abonado.estado IS '1=activo / 2=suspendido / 3=suspendido y retirado / 0=eliminado'; Expected IS at position 33 '.estado IS '1=activo' at cz.startnet.utils.pgdiff.parsers.Parser.expect(Parser.java:86) at cz.startnet.utils.pgdiff.parsers.Parser.expect(Parser.java:47) at cz.startnet.utils.pgdiff.parsers.CommentParser.parseColumn(CommentParser.java:255) at cz.startnet.utils.pgdiff.parsers.CommentParser.parse(CommentParser.java:42) at cz.startnet.utils.pgdiff.loader.PgDumpLoader.loadDatabaseSchema(PgDumpLoader.java:200) at cz.startnet.utils.pgdiff.loader.PgDumpLoader.loadDatabaseSchema(PgDumpLoader.java:236) at cz.startnet.utils.pgdiff.PgDiff.createDiff(PgDiff.java:29) at cz.startnet.utils.pgdiff.Main.main(Main.java:39)

Can you add support for COMMENTS or how can I help you? I am a Java developer anyway.

fordfrog commented 9 years ago

it is supported: http://apgdiff.com/supported_features.php#COMMENT

i guess the problem is only in the fact that you have .

. addressing of the column which is not the syntax created by pg_dump (it instead sets current schema using SET search_path and then does not use schema in object addressing). so if you drop the schema from the statement and put it in SET search_path... if it's not the default schema then it should run without issue.

bsacharski commented 9 years ago

I'm having same issue. My reference db (which has multiple schemas) was exported using http://apgdiff.com/how_to_use_it.php, same for the the target db. So the syntax use should be valid PostgreSQL, yet the error still occurs.

vukbgit commented 6 years ago

I had the same issue: Cannot parse string: COMMENT ON COLUMN public.country_subdivision.create_date IS 'Create Date'; Expected IS at position 45 '.create_date IS 'Cre' Oddly enough it seems that apgdiff has no problem with table comments, in fact preceding line "COMMENT ON TABLE public.country_subdivision IS 'Subdivision';" did not trigger any error. I solved commenting the COMMENT ON COLUMN lines (almost a joke) into dump files. In my case I use a bash script to perform dumping and comparing so in this script, after creating the two dump files and before calling apgdiff I used sed : sed -i 's/COMMENT ON COLUMN/--COMMENT ON COLUMN/' $file_dev sed -i 's/COMMENT ON COLUMN/--COMMENT ON COLUMN/' $file_prod I guess this disables column comments syncing between dbs but I can bear that

kothonet commented 6 years ago

I think that postgresql has change the way it generate the dump. Now it doesn't use search_path anymore.

matthewkmacdonald commented 6 years ago

Postgres changed the way that search path semantics are used in pg_dump in response to this: https://wiki.postgresql.org/wiki/A_Guide_to_CVE-2018-1058:_Protect_Your_Search_Path

The affect took place earlier this year (March 2018) and affects all supported versions of postgres/pg_dump.

This affects all users of apgdiff, so it would be good to see a fix to address it.

Doev commented 6 years ago

I can confirm the bug.

tlkelley commented 6 years ago

Confirmed, as well.