You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tcl.apache.org by mx...@apache.org on 2025/10/07 14:16:22 UTC
(tcl-rivet) branch master updated: Removed method insert from ::DIO::Tdbc and reimplmented 'exec' instead
This is an automated email from the ASF dual-hosted git repository.
mxmanghi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tcl-rivet.git
The following commit(s) were added to refs/heads/master by this push:
new 1a81444 Removed method insert from ::DIO::Tdbc and reimplmented 'exec' instead
1a81444 is described below
commit 1a814446d16ebb602d1a40f9ce93316bbe18e9d9
Author: Massimo Manghi <mx...@apache.org>
AuthorDate: Tue Oct 7 16:16:16 2025 +0200
Removed method insert from ::DIO::Tdbc and reimplmented 'exec' instead
---
ChangeLog | 9 ++++++--
rivet/packages/dio/dio_Tdbc.tcl | 51 ++++++-----------------------------------
2 files changed, 14 insertions(+), 46 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 4018020..2d46036 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,12 @@
+2025-10-07 Massimo Manghi <mx...@apache.org>
+ * rivet/packages/dio/dio_Tdbc.tcl: removing method insert from
+ class ::DIO::Tdbc, the real responsible of honoring SQL statements
+ with bound variables was method exec
+
2025-10-06 Massimo Manghi <mx...@apache.org>
* rivet/packages/dio/dio_Tdbc.tcl: Reimplementing also method
- insert as named parameters requires an SQL statement to be
- evaluated where the array of key-value pairs lives.
+ insert as named parameters requires an SQL statement to be
+ evaluated where the array of key-value pairs lives.
2025-10-06 Massimo Manghi <mx...@apache.org>
* VERSION: Preparing RC as 3.2.7 (which was correctly set on 2024-11-26)
diff --git a/rivet/packages/dio/dio_Tdbc.tcl b/rivet/packages/dio/dio_Tdbc.tcl
index 096065c..5c3469a 100644
--- a/rivet/packages/dio/dio_Tdbc.tcl
+++ b/rivet/packages/dio/dio_Tdbc.tcl
@@ -80,6 +80,8 @@ namespace eval DIO {
if {$connector == ""} { open }
}
+ public method tdbc_connector {} { return $connector }
+
public method open {} {
set connector_cmd "${tdbc_connector}::connection create ${tdbc_connector}#$connector_n"
if {$user != ""} { lappend connector_cmd -user $user }
@@ -151,45 +153,6 @@ namespace eval DIO {
return "INSERT INTO $myTable ([join $vars {,}]) VALUES ([join $named_pars_l {,}])"
}
- #
- # insert - if we want to exploit the named parameters mechanism we
- # need to evaluate the SQL statement in the same context where the
- # array of key-value pairs lives. Therefore we can't rely on the 'exec' method
- #
-
- method insert {table arrayName} {
- upvar 1 $arrayName row_array
- set sql [build_insert_query row_array [::array names row_array] $table]
-
- $this check_connector
- set tdbc_statement [$connector prepare $sql]
-
- # errorinfo is a public variable of the
- # parent class Database. Not a good
- # object design practice
-
- if {[catch {set tdbc_result [$tdbc_statement execute]} e errorinfo]} {
-
- # we must store also the TDBC SQL statement as it owns
- # the TDBC results set represented by tdbc_result. Closing
- # a tdbc::statement closes also any active tdbc::resultset
- # owned by it
-
- set result_obj [$this result TDBC -error 1 \
- -errorinfo [::list $errorinfo] \
- -resultid $tdbc_result \
- -statement $tdbc_statement \
- -isselect false \
- -fields [::list [$tdbc_result columns]]]
- set errinf [$result_obj errorinfo]
- puts "errorinfo: $errorinfo"
- $result_obj destroy
- return -code error "Got '$e' executing '$sql'"
- }
-
- return 1
- }
-
#
# exec
#
@@ -203,13 +166,12 @@ namespace eval DIO {
if {[::string index $sql end] == ";"} {set sql [::string range $sql 0 end-1]}
set is_select [regexp -nocase {^\(*\s*select\s+} $sql]
- set tdbc_statement [$connector prepare $sql]
+ set tdbc_statement [uplevel 1 $connector prepare [::list $sql]]
- # errorinfo is a public variable of the
- # parent class Database. Not a good
- # object design practice
+ # errorinfo is a public variable of the parent class Database.
+ # Not a good object design practice
- if {[catch {set tdbc_result [$tdbc_statement execute]} errorinfo]} {
+ if {[catch {set tdbc_result [uplevel 1 $tdbc_statement execute]} errorinfo]} {
set result_obj [$this result TDBC -error 1 -errorinfo [::list $errorinfo] -isselect false]
} else {
@@ -226,6 +188,7 @@ namespace eval DIO {
return $result_obj
}
+
}
::itcl::class TDBCResult {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tcl.apache.org
For additional commands, e-mail: commits-help@tcl.apache.org