Postgres Join Error

Postgres Join Error

bcavalieribcavalieri Posts: 2Questions: 0Answers: 0
edited November 2012 in Editor
I'm getting the following error when trying to join 2 postgres tables:
[quote]Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42602]: Invalid name: 7 ERROR: invalid name syntax
LINE 6: pg_class.oid = 'sites as sites'::regclass AND[/quote]

When I look in the postgres logs I see:
[code]
SELECT pg_attribute.attname, format_type(pg_attribute.atttypid, pg_attribute.atttypmod)
FROM pg_index, pg_class, pg_attribute
WHERE
pg_class.oid = 'sites as sites'::regclass AND
indrelid = pg_class.oid AND
pg_attribute.attrelid = pg_class.oid AND
pg_attribute.attnum = any(pg_index.indkey)
AND indisprimary;
[/code]

Far as I know you can't have an alias in the where statement with postgres. Any ideas howto keep the alias in the where from happening?

Replies

  • bcavalieribcavalieri Posts: 2Questions: 0Answers: 0
    As a work around for now in Join.php I've done:
    [code]
    // Set up the JOIN query
    $stmt = $dte->db()
    ->query( 'select' )
    ->get( $pkeyTable.'.'.$joinField.' as _dte_pkey' )
    ->get( $this->_fields('get') )
    ->table( $dteTable );
    //->table( $dteTable .' as '. $dteTableAlias );
    [/code]
  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    Can you show me the code that you use which results in the error so I can reproduce and fix the issue? Is it the commented out like that cases an issue?

    Allan
This discussion has been closed.