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 00fa07e Fix sqlite3 connection creation, add mariadb and sqlite
aliases, filtering unrecognized driver names
00fa07e is described below
commit 00fa07ea210a78ff474dd38bb42ab9908d2f47b8
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 2a220dc..5c1af76 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]