igaster/laravel_cities

PDOException on seed

Closed this issue · 4 comments

DB postgresql.

PDOException : SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "" LINE 1: SELECT MAX(right`) as maxRight FROM geo
^

at /xx/vendor/igaster/laravel_cities/src/commands/seedGeoFile.php: 25
21: $this->geoItems = new geoCollection();
22: }
23:
24: public function sql($sql){
25: $result = $this->pdo->query($sql);
26: if($result === false)
27: throw new Exception("Error in SQL : '$sql'\n".PDO::errorInfo(), 1);
28:
29: return $result->fetch();
30: }

Exception trace:

1 PDO::query("SELECT MAX(right) as maxRight FROM geo")
/xx/vendor/igaster/laravel_cities/src/commands/seedGeoFile.php : 25

2 Igaster\LaravelCities\commands\seedGeoFile::sql("SELECT MAX(right) as maxRight FROM geo")
/xx/vendor/igaster/laravel_cities/src/commands/seedGeoFile.php : 113

Please use the argument -v to see more details.

I have test it only on mySql. I checked the docs on postgresql, and it doesn't seem like an invalid query...

I should find some time to test it on postgresql too... Maybe 'right' is a reserved word or something like this.

The backticks are the cause of the issue, also raises and fixes another issue with more backticks.

See Pull Request 15:
#15

New PR opened - seems my last PR broke it for mysql, new pull request checks the db driver.

No problem! Installation script was not covered by tests... So it was my fault too :-)