[DBIx-Class-Devel] [sql-translator] Sql keyword field types (#25)

Roy Storey notifications at github.com
Tue Dec 18 23:56:43 GMT 2012


Running
```bash
sqlt -f DBI --dsn 'dbi:Pg:host=<host>;dbname=<dbname>' --db-user <db-user> -t Dumper --producer-dsn 'dbi:Pg:host=<host>;dbname=<dbname>' --producer-db-user <db-user> > dumper.pl

perl dumper.pl --no-comments --add-truncate > dbname.data.sql
```

results in 
```plain
DBD::Pg::st execute failed: ERROR:  syntax error at or near "desc"
LINE 1: select id, create_time, update_time, name, desc, form_values...
                                                   ^ at dumper.pl line 1665.
DBD::Pg::st execute failed: ERROR:  syntax error at or near "desc"
LINE 1: select id, create_time, update_time, name, desc, form_values...
                                                   ^ at dumper.pl line 1665.
```

This is mainly due to columns named "desc" in tables. Quoting the column names in the SELECT statement cures this. Whether this is a fix for all database engines I'm not sure.

Additionally timestamp and bytea fields are output as data type numbers, but this fails on loading into MySQL.
```plain
ERROR 1064 (42000) at line 205: You have an error in your SQL syntax; 
```

This patch fixes both of these "features".

You can merge this Pull Request by running:

  git pull https://github.com/kiwiroy/sql-translator sql_keyword_field_types

Or you can view, comment on it, or merge it online at:

  https://github.com/dbsrgits/sql-translator/pull/25

-- Commit Summary --

  * correct quoting of timestamp fields in output and keyword fields in select
  * add bytea to the datatypes that map to string and are hence quoted

-- File Changes --

M lib/SQL/Translator/Producer/Dumper.pm (4)

-- Patch Links --

https://github.com/dbsrgits/sql-translator/pull/25.patch
https://github.com/dbsrgits/sql-translator/pull/25.diff


---
Reply to this email directly or view it on GitHub:
https://github.com/dbsrgits/sql-translator/pull/25
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class-devel/attachments/20121218/a2ebe2ec/attachment-0001.htm


More information about the DBIx-Class-Devel mailing list