Closed sn0opy closed 4 years ago
there's nothing screwed-up... if there's an issue with postgreSQL, we will find it... but no one it helped when you spread your anger around here.
It was a fix for an issue that has clearly not being tested with PostgreSQL. Now please post the actual problem instead of blaming people for not testing stuff beforehand.
@stehlo1 you don't need write in your comments that you'll delete them shortly... I can do that for you! Please only post comments that'll help solving the issue and are fine to be archived.
Hello Guys,
I confirm that with 3.7.2
release there is a problem with PostgreSQL mapping, after inserting a new entry the fields values are set to null.
Exactly.
In PostgreSQL 9.6 when I call $entity->save();
in Release 3.7.2 it behaves similar to $entity->save() && $entity->reset();
after saving the entry properly. So I have to do the extra step - load the entity by some other Unique identificator (if any available) :-/
Initial setup: $db = new DB\SQL( $f3->get('devdb'), $f3->get('devdbusername'), $f3->get('devdbpassword'), array( \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION) );
Going from release 3.6 to 3.7-3-dev from 2 days ago. PostgreSQL 10 & 11 I had to change some pieces of code all over an existing app :+1:
$this->scenario = new DB\SQL\Mapper($this->db, 'scenarios');
if ((integer) $f3->get('POST.id') == -1)
$id = NULL;
else {
$id = (integer) $f3->get('POST.id');
$this->scenario->load(array('id=?', $id));
}
$this->scenario->id = $id;
$this->scenario->code = $f3->get('POST.code');
$this->scenario->description = $f3->get('POST.description');
<other fields updated>....
$this->scenario->save();
Note the id field of table scenario is defined as
id integer not null default nextval('scenario_seq');
in release 3.6 this works fine (inserting a new or updating the relevant record) in 3.7.3-dev the id field is send to postgres as 0 when it is set as null;
Workaround : I stop touching the ID field altogether in my php code
if the id field should be null, I do the a reset
$this->scenario->reset();
otherwise
$this->scenario->load(array('id=?', $id));
I never had to do any change in F3 3.5 or 3.6, only in 3.7
It seems to me that setting the field to null sets it to 0 instead
HTH
You don't need to change your app code, it was a false assumption with a quick fix I did. I'll try to implement @xfra35 ´s suggestion from https://github.com/bcosca/fatfree/issues/1175#issuecomment-583334337 which then will properly find and track autoincrement fields.
alright... so I came up with this fix in the latest commit.. if anyone want to test that please too? I've checked it in mysql, sqlite, and postgre... sql server only in fiddle and should be fallback fine to previous behaviour in oracle and others.
@ikkez At first glance and for my use case, your latest commit seems to be working fine. I leave it in place in my source tree and report back in the next few days to see if there are any other issues. Note I copied sql.php & mapper.php over the 3.7.3-dev branch Thanks a lot for the very quick turnaround
until release of 3.7.3 I had to set composer to
"bcosca/fatfree": "3.7.1",
"bcosca/fatfree-core": "3.7.1",
Is the last statemt saying that we should rather go for "bcosca/fatfree": "3.7.3-dev", "bcosca/fatfree-core": "3.7.3-dev", ?
"bcosca/fatfree-core": "dev-master",
should be enough, @slavino
Loading composer repositories with package information Updating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages.
Problem 1
aaaargh...
Please perform a release of 3.7.3 :)
Try: "bcosca/fatfree-core": "dev-master#a82f136 as 3.7.2"
Latest fix should solve this issue.. Please reopen if problem persists.
So you already released it in 3.7.3 ?
I was about to report the same issue. I'm wondering if there is some estimated release date for 3.7.3
?
composer require bcosca/fatfree-core:"dev-master#28e7e75 as 3.7.3-dev"
is a saver here :+1:
As reported by @stehlo1. There seems to be an issue with this change. https://github.com/bcosca/fatfree-core/commit/5ba562f60a934664e8df9e392366f2703e19c2e5
@stehlo1 please commend below with a proper error description.