Closed simonhunt8475 closed 9 months ago
Can't reproduce. https://krisrice.io/quick-sql-standalone.html running version 1.1.4
person
person_name
# settings = { PK: "GUID" }
outputs
-- create tables
create table person (
id number default on null to_number(sys_guid(), 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
constraint person_id_pk primary key,
person_name varchar2(4000 char)
);
-- triggers
create or replace trigger person_biu
before insert or update
on person
for each row
begin
if :new.id is null then
:new.id := to_number(sys_guid(), 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
end if;
end person_biu;
/
In soon to be released version 1.2.1, the trigger is nuked.
You need to use the setting # settings = { PK: "GUID", "prefixpkwithtname": "Y" } then you'll see that the trigger doesnt include the prefix table name. If you're nuking the trigger, then that will do the job, thanks.
1.2.1 is out, and you can test it here. The trigger code for GUID is not generated.
Hi, this is not working if you use the setting api:Y. The API's created use a column ID that is not prefixed with the table name, which then errors. I will raise a new issue.
Test case:
person
person_name
# settings = { PK: "GUID", api:y, "prefixpkwithtname": "Y" }
Output:
...
-- APIs
create or replace package person_api
is
procedure get_row (
p_id in number,
--------^^^
p_person_name out varchar2
);
...
Closing again: duplicate of 57
When using the setting "Prefix primary keys with a sysguid population method, then a trigger is created that uses the :new.id rather than :new.[table name]_id. This causes an error when the script is run.
Populating the primary key in the trigger is not actually needed anyway as there is a default value on the column in the table.