From 6fea8924aff0e9349e996c0c811db12dd460063f Mon Sep 17 00:00:00 2001 From: Will Budic Date: Thu, 18 Sep 2025 11:57:05 +1000 Subject: [PATCH] bug fix: view mapping to ID data not working cross platform. --- system/modules/CNFMeta.pm | 17 ++++++++--------- system/modules/CNFParser.pm | 9 +++++++-- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/system/modules/CNFMeta.pm b/system/modules/CNFMeta.pm index 9239965..7c11d6f 100644 --- a/system/modules/CNFMeta.pm +++ b/system/modules/CNFMeta.pm @@ -120,7 +120,7 @@ sub _metaTranslateDataHeader { } else { $body .= "\"$hdr\" INT UNIQUE PRIMARY KEY GENERATED ALWAYS AS IDENTITY,\n"; - $where_id = "$hdr = ?"; + $where_id = "\"$hdr\" = ?"; } $spec[$i] = $CNF_DATA_TYPES{INT}; $primary = $hdr; @@ -136,12 +136,11 @@ sub _metaTranslateDataHeader { $primary = $hdr; $primary_set = 1; $idType = 'CNF_ID'; #UPDATE "main"."TASKS" SET "Completed"=? WHERE "_rowid_"='10' - $where_id = "\"$hdr\" = ?"; + $where_id = "\"$hdr\" = ?"; }elsif($hdr =~ s/$ID/""/ei){ #This is ID prefix to some other data id stored in this table, usually one to one/many relationship. $body .= "\"$hdr\" INTEGER CHECK (\"$hdr\">0),\n"; - $spec[$i] = $CNF_DATA_TYPES{INT}; - $primary = $idType = 'ID' + $spec[$i] = $CNF_DATA_TYPES{INT}; }elsif($hdr =~ s/$INDEX/""/ei){ # This is where CNF instructs to make a indexed lookup type field, # for inside database fast selecting, hashing, caching and other queries. @@ -166,12 +165,12 @@ sub _metaTranslateDataHeader { $body .= "\"$hdr\" NOT NULL,\n"; $spec[$i] = $CNF_DATA_TYPES{NUM}; }elsif($hdr =~ s/$BOOL/''/ei){ - if($isPostgreSQL){ - $body .= "\"$hdr\" BOOLEAN NOT NULL CHECK (\"$hdr\" IN (0, 1)),\n"; - }else{ - $body .= "\"$hdr\" BOOLEAN NOT NULL,\n"; + # if($isPostgreSQL){ + # $body .= "\"$hdr\" BOOLEAN NOT NULL CHECK (\"$hdr\" IN (0, 1)),\n"; + # }else{ + $body .= "\"$hdr\" BOOLEAN NOT NULL,\n"; - } + # } $spec[$i] = $CNF_DATA_TYPES{BOOL}; }elsif($hdr =~ s/$TEXT/""/ei){ $body .= "\"$hdr\" TEXT NOT NULL CHECK (length(\"$hdr\")<=$SQL_CNF_VAR_LENGTH),\n"; diff --git a/system/modules/CNFParser.pm b/system/modules/CNFParser.pm index 9752080..3ef1efd 100644 --- a/system/modules/CNFParser.pm +++ b/system/modules/CNFParser.pm @@ -829,7 +829,12 @@ sub doDATAInstructions_{ my ($self,$e,$v,$t,$d)=@_; my $ctpys = $hdr[$MHDR{COL_TYPES}]; my $tbody = ${$hdr[$MHDR{T_BODY} ]}; my $tmeta = $hdr[$MHDR{TABLE_META}]; - $idtyp = "AUTOINCREMENT" if $tbl_id_spec eq 'ID'; + #Activate autonumbering to be done HERE, based on column name or type. + if($tbl_id_spec eq 'ID' && $idtyp ne 'CNF_ID'){ + $idtyp = "AUTOINCREMENT"; $isAutonumber = 1 + }elsif($idtyp eq 'CNF_ID'){ + $isAutonumber = 1 + } $self->SQL()->createTable( $e, $tbody, $idtyp, $tmeta ) } my @rel = CNFMeta::_deRefArray($hdr[$MHDR{RELATIONS}]); @@ -1633,7 +1638,7 @@ sub log { my %log = $self -> property('%LOG'); my $time = CNFDateTime -> now(exists($self->{TZ})?{TZ=>$self->{TZ}}:undef) -> toTimestamp(); - $message = "$type $message" if $isWarning; + $message = "$type $message" if $isWarning; $message = "" if not $message; if($message =~ /^ERROR/ || ($isWarning && $self->{ENABLE_WARNINGS})){ $message =~ s/(\s+line\s)(\d+)\.*\s+/:$2\n/gm; warn $time . " " .$message; -- 2.34.1