-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[BUG]: Model - Update - Postgres NULL value is not allowed on Phalcon 4.0.4 #14862
Comments
I will try to help you, but you can tell me your postgres, phalcon and php version, I'm not having this issue. and if possible some code example and the table. Thanks |
@Gamblt Can you give more specific example with code? |
I confirm on Postgresql 12 PHP: 7.4
Model: class User extends \Phalcon\Mvc\Model
{
public ?int $id = null;
public ?string $login = null;
public ?string $password = null;
public ?string $updated_at = null;
public function initialize()
{
$this->setSource('users');
$this->useDynamicUpdate(true);
}
} Schema CREATE TABLE "users" (
"id" SERIAL PRIMARY KEY,
"login" CHARACTER VARYING(255) NOT NULL,
"password" CHARACTER VARYING(255) NULL,
"updated_at" timestamp NULL
); To reproduce: $user = new User();
$user->login = 'kek';
$user->save();
foreach ($user->getMessages() as $message) {
echo $message->getMessage(); // password is required, updated_at is required
} |
Yes. It's on Phalcon 4.0.4 from binary, PHP7.4 and Postgresql12.1 |
The problem is in the Adapter/Pdo/Postgresql class. if field [5] == "NO" {
let definition["notNull"] = true;
} and that is correct if field [5] == "YES" {
let definition["notNull"] = false;
} that fixes the problem The fix already exists for Mysql: 8038065 |
# Conflicts: # tests/_data/assets/schemas/pgsql.sql # tests/_data/fixtures/Migrations/OrdersProductsMigration.php # tests/_envs/pgsql.yml
#14862 - Swap condition if column allows null values in PostgreSQL
Fixed in #14876 |
When I try to save a NULL value on postgresql, it does not save;
$model->getMessages() "return field1,field2,field3.... is required
I've get model from database and try to save it but got required errors on NULL values.
It's similar to issue #14722
The text was updated successfully, but these errors were encountered: