]> lifelog.hopto.org Git - PerlCNF.git/commitdiff
bug fix: view mapping to ID data not working cross platform.
authorWill Budic <redacted>
Thu, 18 Sep 2025 01:57:05 +0000 (11:57 +1000)
committerWill Budic <redacted>
Thu, 18 Sep 2025 01:57:05 +0000 (11:57 +1000)
system/modules/CNFMeta.pm
system/modules/CNFParser.pm

index 92399654e45afb77032d0b0ac7e2bd8f9219fe4c..7c11d6f663875761f91cac52b8999e0d43fb49b9 100644 (file)
@@ -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";
index 9752080a74e1c9c4680681d0c853e79303b814de..3ef1efdc947c002fa156c6bc0723c100a7943c14 100644 (file)
@@ -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;