Open
Description
Questions? Forum: https://phalcon.io/forum or Discord: https://phalcon.io/discord
Describe the bug
When updating the model, phalcon passes as a string the name of the function specified in the column as the name of the function for the default value.
To Reproduce
Steps to reproduce the behavior:
CREATE FUNCTION public.gen_random_uuid() RETURNS uuid
LANGUAGE c PARALLEL SAFE
AS '$libdir/pgcrypto', 'pg_random_uuid';
CREATE TABLE public.test
(
id serial NOT NULL,
name text COLLATE pg_catalog."default",
cuuid uuid NOT NULL DEFAULT public.gen_random_uuid()
)
TABLESPACE pg_default;
Provide minimal script to reproduce the issue
class TestModel extends \Phalcon\Mvc\Model
{
public $id;
public $name;
public $cuuid;
public function initialize()
{
$this->setSchema("public");
$this->setSource("test");
}
}
$m = new TestModel;
$m->name = 'Hello';
$m->save();
$m->name = 'World';
$m->save();
Error ouptut
SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type uuid: "public.gen_random_uuid()"
CONTEXT: unnamed portal parameter $2 = '...'%
Db log:
[2021-12-13T13:43:59+03:00][debug] INSERT INTO "public"."test" ("name", "cuuid", "id") VALUES (?, DEFAULT, DEFAULT)
[2021-12-13T13:43:59+03:00][debug] array (
0 => 'Hello',
)
[2021-12-13T13:43:59+03:00][debug] UPDATE "public"."test" SET "name" = ?, "cuuid" = ? WHERE "id" = ?
[2021-12-13T13:43:59+03:00][debug] array (
0 => 'World',
1 => 'public.gen_random_uuid()',
2 => '2',
)
Details
- Phalcon version: (
php --ri phalcon
)
Version => 4.1.2
Build Date => May 1 2021 19:01:51
Powered by Zephir => Version 0.12.21-8a412a1
Directive => Local Value => Master Value
phalcon.db.escape_identifiers => On => On
phalcon.db.force_casting => Off => Off
phalcon.orm.case_insensitive_column_map => Off => Off
phalcon.orm.cast_last_insert_id_to_int => Off => Off
phalcon.orm.cast_on_hydrate => Off => Off
phalcon.orm.column_renaming => On => On
phalcon.orm.disable_assign_setters => Off => Off
phalcon.orm.enable_implicit_joins => On => On
phalcon.orm.enable_literals => On => On
phalcon.orm.events => On => On
phalcon.orm.exception_on_failed_save => Off => Off
phalcon.orm.exception_on_failed_metadata_save => On => On
phalcon.orm.ignore_unknown_columns => Off => Off
phalcon.orm.late_state_binding => Off => Off
phalcon.orm.not_null_validations => On => On
phalcon.orm.update_snapshot_on_save => On => On
phalcon.orm.virtual_foreign_keys => On => On
phalcon.warning.enable => On => On
- PHP Version: (
php -v
)
PHP 7.4.26 (cli) (built: Nov 22 2021 09:47:04) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.26, Copyright (c), by Zend Technologies
- Operating System:
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
- Installation type: Compiling from source || installing via package manager
- Other related info (Database, table schema):
- postgres (PostgreSQL) 14.1
Additional context
Add any other context about the problem here.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Backlog