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

PostgreSQL issue when dealing with table without PRIMARY KEY #1217

Open
slavino opened this issue Feb 25, 2021 · 1 comment
Open

PostgreSQL issue when dealing with table without PRIMARY KEY #1217

slavino opened this issue Feb 25, 2021 · 1 comment

Comments

@slavino
Copy link

slavino commented Feb 25, 2021

return call_user_func_array([$this->pdo,$func],$args);

https://stackoverflow.com/questions/32991564/how-to-check-in-postgres-that-lastval-is-defined

seems that table needs to have PRIMARY KEY in order to fulfill INSERT statement without throwing an Error

setup:
Windows machine
Postgres 9.6
PHP 7.4.3 Development Server

SQLSTATE[55000]: Object not in prerequisite state: 7 ERROR:  lastval is not yet defined in this session [\workspace\domain.com\devtracks\vendor\bcosca\fatfree-core\db\sql.php:524]

[/workspace/domain.com/_sub/devtracks/vendor/bcosca/fatfree-core/db/sql.php:524] call_user_func_array()
[/workspace/domain.com/_sub/devtracks/vendor/bcosca/fatfree-core/db/sql/mapper.php:489] DB\SQL->__call()
[/workspace/domain.com/_sub/devtracks/vendor/bcosca/fatfree-core/db/cursor.php:245] DB\SQL\Mapper->insert()
[/workspace/domain.com/_sub/devtracks/app/MVC/Controller/MainController.php:58] DB\Cursor->save()
[/workspace/domain.com/_sub/devtracks/vendor/bcosca/fatfree/lib/base.php:1960] MainController->locusTrackerNoResponse()
[/workspace/domain.com/_sub/devtracks/vendor/bcosca/fatfree/lib/base.php:1759] Base->call()
[/workspace/domain.com/_sub/devtracks/index.php:41] Base->run()

PS: the silly part is that it actually successfully inserts such row and only hint is in the log file.

@ikkez
Copy link
Collaborator

ikkez commented Feb 25, 2021

Yes the mapper is trying to reload the inserted record to obtain default values from the table, but without a returning pkey, that's not possible, hence the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants