oracle / quicksql

A library for generating DDL SQL and entity-relationship-diagrams from Quick SQL code
Universal Permissive License v1.0
53 stars 11 forks source link

Erroneous alter statement for "pk"="guid" #28

Closed vadim-tropashko closed 9 months ago

vadim-tropashko commented 11 months ago

Input:

# settings = {"pk":"GUID"}
students /insert 2 
    name

Output:

create table students (
    id      number default on null to_number(sys_guid(), 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') 
            constraint students_id_pk primary key,
    name    varchar2(255 char)
);

-- triggers
create or replace trigger students_biu
    before insert or update
    on students
    for each row
begin
    if :new.id is null then
        :new.id := to_number(sys_guid(), 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
    end if;
end students_biu;
/

-- load data

insert into students (
    id,
    name
) values (
    1,
    'Dean Stephens'
);
insert into students (
    id,
    name
) values (
    2,
    'Brett Matthews'
);

commit;

alter table students
modify id generated always  as identity restart start with 3;

Expected:

create table students (
    id                             number default on null to_number(sys_guid(), 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') 
                                   constraint students_id_pk primary key,
    name                           varchar2(255 char)
)
;

-- load data

insert into students (
    name
) values (
    'Mark'
);

insert into students (
    name
) values (
    'Words'
);
alahe commented 11 months ago

The same erroneous alter statement also come with "pk"="SEQ"

Input

# settings = {"pk":"SEQ"} 
students /insert 2 
    name
vadim-tropashko commented 9 months ago

in 1.2.1