theory / tap-parser-sourcehandler-pgtap

TAP::Parser::SourceHandler::pgTAP
http://search.cpan.org/dist/TAP::Parser::SourceHandler::pgTAP
11 stars 13 forks source link

Double quotes on defaut value #7

Closed rodo closed 8 years ago

rodo commented 8 years ago

With column with default value as text the generated file is bugy, I double the quote to FIX this

theory commented 8 years ago

it's not just columns. Its damn near every object. Frankly most of the code here should be updated to use quote_literal() when selecting objects from the database, and the resulting names written out as-is.s

rodo commented 8 years ago

Thanks for the heads up on quote_literal() I've updated my PR, only on the colums for the moment, I'll look forward to do the replace on other parts. By now I've just fixed this part because I'm working on another PR about triggers, I need to check triggers so I'm working on a triggers_are() function.

theory commented 8 years ago

Sorry, should be quote_ident(), not quote_literal(). My fault. Was thinking of doing an audit of all objects after merging #6.

rodo commented 8 years ago

quote_ident() doesn't work if you have for example a serial

table_public.document.pg .. 1/? psql:table_public.document.pg:97: ERROR:  column "nextval('document_id_seq'::regclass)" does not exist
LINE 1: ...LECT col_default_is(   'document', 'id', "nextval('...

The tap.file contains :

SELECT col_default_is(   'document', 'id', "nextval('document_id_seq'::regclass)");

We need to quote_literal and remove the cast orperator in certain case, don't we ?

rodo commented 8 years ago

May be we can find a more beautiful way but what I did in is functionnal https://github.com/rodo/tap-parser-sourcehandler-pgtap/pull/5/files

theory commented 8 years ago

Yeah, sorry, you're right, quote_literal() is the correct approach here.

theory commented 8 years ago

I cherry-picked this change in 8162bb5, thanks!