Postgres doesn't return the table name when you make a query, so right now where mysql would give you a mapping containing both "column" and "table.column", postgres gives you "column" and ".column" for no reason. Looking at the code, it appears as though this is intentional? Is there any objection to getting rid of the .column, something like the attached patch?
Adam
And of course, I forgot the attachment. Here it is.
On Tue, 22 Nov 2005 14:41:15 -0500 Adam Montague amontague@siriushosting.com wrote:
Postgres doesn't return the table name when you make a query, so right now where mysql would give you a mapping containing both "column" and "table.column", postgres gives you "column" and ".column" for no reason. Looking at the code, it appears as though this is intentional? Is there any objection to getting rid of the .column, something like the attached patch?
Adam
On Tue, Nov 22, 2005 at 02:41:15PM -0500, Adam Montague wrote:
Postgres doesn't return the table name when you make a query, so right now where mysql would give you a mapping containing both "column" and "table.column", postgres gives you "column" and ".column" for no reason.
does mysql always give table.column? i thought i remembered seeing .column there too...
greetings, martin.
In the last episode (Nov 22), Martin Bhr said:
On Tue, Nov 22, 2005 at 02:41:15PM -0500, Adam Montague wrote:
Postgres doesn't return the table name when you make a query, so right now where mysql would give you a mapping containing both "column" and "table.column", postgres gives you "column" and ".column" for no reason.
does mysql always give table.column? i thought i remembered seeing .column there too...
Only if you run a table-less query, I think:
Sql.Sql("mysql://localhost/test")->query("select ename from emp where ename='scott'");
(5) Result: ({ /* 1 element */ ([ /* 2 elements */ "emp.ename": "SCOTT", "ename": "SCOTT" ]) })
Sql.Sql("mysql://localhost/test")->query("select 12");
(6) Result: ({ /* 1 element */ ([ /* 2 elements */ ".12": "12", "12": "12" ]) })
On Tue, 22 Nov 2005 17:38:02 -0600 Dan Nelson dnelson@allantgroup.com wrote:
In the last episode (Nov 22), Martin Bhr said:
On Tue, Nov 22, 2005 at 02:41:15PM -0500, Adam Montague wrote:
Postgres doesn't return the table name when you make a query, so right now where mysql would give you a mapping containing both "column" and "table.column", postgres gives you "column" and ".column" for no reason.
does mysql always give table.column? i thought i remembered seeing .column there too...
Only if you run a table-less query, I think:
Sql.Sql("mysql://localhost/test")->query("select ename from emp where ename='scott'");
(5) Result: ({ /* 1 element */ ([ /* 2 elements */ "emp.ename": "SCOTT", "ename": "SCOTT" ]) })
Sql.Sql("mysql://localhost/test")->query("select 12");
(6) Result: ({ /* 1 element */ ([ /* 2 elements */ ".12": "12", "12": "12" ]) })
Here's an additional patch to get rid of that too. It does change the behaviour of fetch_fields() though, so that if "table" doesn't exist, then its false (0) instead of an empty string. I'm not sure if that's ok or if people would prefer changing res_obj_to_array() to check if table is false or an empty string and leaving fetch_fields() alone.
Adam
On Wed, 23 Nov 2005 22:50:11 +0000 (UTC) "Martin Nilsson (Opera) @ Pike (-) developers forum" 10353@lyskom.lysator.liu.se wrote:
Altering the API will cause lots of regressions. It's better to design a new one.
Altering the API as in changing fetch_fields(), or as in removing the .column junk from query()?
Adam
Altering the API of fetch_fields(). The right fix wrt columns would of course be to have the correct table before the column.
On Thu, 24 Nov 2005 16:45:08 +0000 (UTC) "Martin Nilsson (Opera) @ Pike (-) developers forum" 10353@lyskom.lysator.liu.se wrote:
Altering the API of fetch_fields(). The right fix wrt columns would of course be to have the correct table before the column.
Ok, here's a patch that leaves fetch_fields() behaviour alone and just removes the .column entries from query results when the table name is not available. It works with both postgresql (all the time since it doesn't let you find the table name) and mysql when the query didn't involve a table.
Adam
I applied something similar.
On Tue, 22 Nov 2005 23:46:08 +0100 Martin B_hr mbaehr@email.archlab.tuwien.ac.at wrote:
On Tue, Nov 22, 2005 at 02:41:15PM -0500, Adam Montague wrote:
Postgres doesn't return the table name when you make a query, so right now where mysql would give you a mapping containing both "column" and "table.column", postgres gives you "column" and ".column" for no reason.
does mysql always give table.column? i thought i remembered seeing .column there too...
I'm not sure, I don't really use mysql. I just installed it to test and compare pike's postgres and mysql modules. Maybe old (3.x?) versions of mysql don't give the table name, but 4.1 at least gives table.column and column.
Adam
pike-devel@lists.lysator.liu.se