Set name_sep for default SQL::Abstract to help disambiguate columns #39

wants to merge 1 commit into


None yet

2 participants


When using SQL::Abstract with multiple tables, it is sometimes necessary to disambiguate columns:

$pg->db->select(['foo', 'bar'], [''], {'', => {-ident => ''}});

If SQL::Abstract does not have a name_sep specified, it will attempt to quote the entire table-field name as "" and "" rather than "foo"."id" and "bar"."id", producing an error such as:

DBD::Pg::st execute failed: ERROR:  column "" does not exist
LINE 1: SELECT "" FROM "foo", "bar" WHERE ( "" = "
               ^ at lib/ line 50.

The workaround is to create the Mojo::Pg instance with:

    $pg = Mojo::Pg
      ->abstract(SQL::Abstract->new(quote_char => '"', name_sep => '.'))

However, since the name_sep and quote_char values are intrinsic to Postgres, it makes sense for these to be the setting on the default SQL::Abstract object.

@kraih kraih closed this in 0bfd3e7 Feb 18, 2017
kraih commented Feb 18, 2017

Thank you, applied with tests and documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment