This is an automated email from the ASF dual-hosted git repository. mxmanghi pushed a commit to branch 3.2 in repository https://gitbox.apache.org/repos/asf/tcl-rivet.git
commit 0bc6edf0cc9ae9bafe4646594d125fde355aea8e Author: Massimo Manghi <[email protected]> AuthorDate: Fri Oct 3 16:00:59 2025 +0200 Fix sqlite3 connection creation, add mariadb and sqlite aliases, filtering unrecognized driver names --- ChangeLog | 6 ++++++ rivet/packages/dio/dio_Tdbc.tcl | 38 +++++++++++++++++++++++++++++++------- rivet/packages/dio/pkgIndex.tcl | 2 +- 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 57b65f1..9a3a48c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2025-10-03 Massimo Manghi <[email protected]> + * rivet/packages/dio/dio_Tdbc.tcl: restricting constructor action on the set of tdbc + known drivers. Creating 'mariadb' and 'sqlite' aliases for mysql and sqlite3 + respectively. Adopting a specific tdbc connector creator form when creating a + sqlite3 handle + 2025-10-02 Massimo Manghi <[email protected]> * rivet/packages/dio/dio.tcl: definining command ::rivet::lempty if not present as it's extensively used but available only when running from mod_rivet (DIO diff --git a/rivet/packages/dio/dio_Tdbc.tcl b/rivet/packages/dio/dio_Tdbc.tcl index 83c764c..98eed2b 100644 --- a/rivet/packages/dio/dio_Tdbc.tcl +++ b/rivet/packages/dio/dio_Tdbc.tcl @@ -21,7 +21,7 @@ package require tdbc package require DIO 1.2 -package provide dio_Tdbc 1.2.1 +package provide dio_Tdbc 1.2.2 namespace eval DIO { ::itcl::class Tdbc { @@ -29,6 +29,7 @@ namespace eval DIO { private common connector_n 0 private variable connector + private variable connector_name private variable tdbc_connector private variable tdbc_arguments [list -encoding \ -isolation \ @@ -43,10 +44,28 @@ namespace eval DIO { #puts "tdbc interface: $interface_name" set connector_name [::string tolower $interface_name] - if {$connector_name == "oracle"} { - set connector_name "odbc" - } elseif {$connector_name == "postgresql"} { - set connector_name "postgres" + switch $connector_name { + "oracle" { + set connector_name "odbc" + } + "postgresql" { + set connector_name "postgres" + } + "sqlite" { + set connector_name "sqlite3" + } + "mariadb" { + set connector_name "mysql" + } + "sqlite3" - + "odbc" - + "postgres" - + "mysql" { + # OK + } + default { + return -code error -errorcode invalid_tdbc_driver "Invalid TDBC driver '$connector_name'" + } } set tdbc_connector "tdbc::${connector_name}" @@ -63,7 +82,13 @@ namespace eval DIO { public method open {} { set connector_cmd "${tdbc_connector}::connection create ${tdbc_connector}#$connector_n" if {$user != ""} { lappend connector_cmd -user $user } - if {$db != ""} { lappend connector_cmd -db $db } + if {$db != ""} { + if {$connector_name == "sqlite3"} { + lappend connector_cmd $db + } else { + lappend connector_cmd -db $db + } + } if {$pass != ""} { lappend connector_cmd -password $pass } if {$port != ""} { lappend connector_cmd -port $port } if {$host != ""} { lappend connector_cmd -host $host } @@ -71,7 +96,6 @@ namespace eval DIO { if {$clientargs != ""} { lappend connector_cmd {*}$clientargs } #puts "evaluating $connector_cmd" - set connector [eval $connector_cmd] incr connector_n } diff --git a/rivet/packages/dio/pkgIndex.tcl b/rivet/packages/dio/pkgIndex.tcl index e8c3095..3a7cb5b 100644 --- a/rivet/packages/dio/pkgIndex.tcl +++ b/rivet/packages/dio/pkgIndex.tcl @@ -20,4 +20,4 @@ package ifneeded dio_Postgresql 0.1 [list source [file join $dir dio_Postgresql0 package ifneeded dio_Postgresql 1.2 [list source [file join $dir dio_Postgresql.tcl]] package ifneeded dio_Sqlite 0.1 [list source [file join $dir dio_Sqlite01.tcl]] package ifneeded dio_Sqlite 1.2 [list source [file join $dir dio_Sqlite.tcl]] -package ifneeded dio_Tdbc 1.2.1 [list source [file join $dir dio_Tdbc.tcl]] +package ifneeded dio_Tdbc 1.2.2 [list source [file join $dir dio_Tdbc.tcl]] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
