Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pgsql: extractSchema() with postgresql fails #707

Closed
peterdd opened this issue Mar 18, 2021 · 0 comments
Closed

pgsql: extractSchema() with postgresql fails #707

peterdd opened this issue Mar 18, 2021 · 0 comments

Comments

@peterdd
Copy link
Contributor

peterdd commented Mar 18, 2021

Using the extractSchema() of adodb-xmlschema03.inc.php with a postgresql database is not working:

Testscript with existing adodbtest database:

<?php
$adodbdir='ADOdb/';

include_once $adodbdir.'adodb.inc.php';
include_once $adodbdir.'adodb-xmlschema03.inc.php';

/*
$driver='mysqli';
$host='127.0.0.1';
$user='';
$password='';
$database='adodbtest';
*/

$driver='postgres';
$host='127.0.0.1';
$user='';
$password='';
$database='adodbtest';

$db = ADONewConnection($driver);
$db->debug=true;
$db->connect($host, $user, $password, $database);
$schema = new adoSchema($db);

$xml = $schema->extractSchema(true);

echo $xml;
PHP Warning:  pg_query(): Query failed: ERROR:  argument of WHERE must be type boolean, not type integer
LINE 1: SELECT * FROM flyspray_history WHERE -1
                                             ^ in /srv/www/htdocs/ADOdb/drivers/adodb-postgres7.inc.php on line 259
-1: ERROR:  argument of WHERE must be type boolean, not type integer
LINE 1: SELECT * FROM flyspray_history WHERE -1
                                             ^
	ADOConnection._Execute(SELECT * FROM flyspray_history WHERE -1, false)% line 1383, file: /srv/www/htdocs/ADOdb/adodb.inc.php
ADOConnection.Execute(SELECT * FROM flyspray_history WHERE -1)% line 2095, file: /srv/www/htdocs/ADOdb/adodb-xmlschema03.inc.php
adoSchema.extractSchema(true)% line   25, file: /srv/www/htdocs/extractsch.php

Fix is probably rewriting the query so the WHERE clause is always a boolean false if we are just interested in field definition, not data, right?

adodbtest=# create table adodbtest(id int);
CREATE TABLE
adodbtest=# insert into adodbtest values (10),(20),(30);
INSERT 0 3
adodbtest=# select * from adodbtest where -1;
ERROR:  argument of WHERE must be type boolean, not type integer
LINE 1: select * from adodbtest where -1;
                                      ^
adodbtest=# select * from adodbtest where 0=1;
 id 
----
(0 rows)
@dregad dregad added this to the v5.21.1 milestone Mar 23, 2021
@dregad dregad linked a pull request Mar 27, 2021 that will close this issue
dregad pushed a commit that referenced this issue Mar 27, 2021
This caused an error on PostgreSQL:
Query failed: ERROR:  argument of WHERE must be type boolean, not type integer

Fixes #707

Signed-off-by: Damien Regad <dregad@mantisbt.org>
@dregad dregad closed this as completed Mar 27, 2021
@mnewnham mnewnham changed the title extractSchema() with postgresql fails pgsql: extractSchema() with postgresql fails Aug 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants