Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Ticket [0374f302f5] RFE: Please consider supporting dicts in db eval in Tcl interface |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | ticket-0374f302-db-eval-dicts |
Files: | files | file ages | folders |
SHA3-256: |
7822a89cdac5a9937db4823ba96b0dbc |
User & Date: | oehhar 2023-10-15 13:43:53.428 |
References
2023-10-15
| ||
13:46 | • Ticket [0374f302f5] RFE: Please consider supporting dicts in db eval in Tcl interface status still Open with 4 other changes artifact: 9e0adf5190 user: oehhar | |
Context
2023-10-15
| ||
13:43 | Ticket [0374f302f5] RFE: Please consider supporting dicts in db eval in Tcl interface Leaf check-in: 7822a89cda user: oehhar tags: ticket-0374f302-db-eval-dicts | |
2023-09-11
| ||
16:00 | Update TEA files check-in: 1677ce1ad1 user: jan.nijtmans tags: trunk, main | |
Changes
Changes to library/tdbcsqlite3.tcl.
︙ | ︙ | |||
86 87 88 89 90 91 92 | -encoding -isolation -keepcase -readonly -timeout } $option} opt]} { return -code error \ -errorcode [list TDBC GENERAL_ERROR HY000 SQLITE3 \ BADOPTION $option] $opt } switch -exact -- $opt { | | | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | -encoding -isolation -keepcase -readonly -timeout } $option} opt]} { return -code error \ -errorcode [list TDBC GENERAL_ERROR HY000 SQLITE3 \ BADOPTION $option] $opt } switch -exact -- $opt { -encoding { return utf-8 } -isolation { if {[db onecolumn {PRAGMA read_uncommitted}]} { return readuncommitted } else { return serializable |
︙ | ︙ | |||
518 519 520 521 522 523 524 | # The variables of this class all have peculiar names. The reason is # that the RunQuery method needs to execute with an activation record # that has no local variables whose names could conflict with names # in the SQL query. We start the variable names with hyphens because # they can't be bind variables. variable -set {*}{ | | | | > | | | | 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 | # The variables of this class all have peculiar names. The reason is # that the RunQuery method needs to execute with an activation record # that has no local variables whose names could conflict with names # in the SQL query. We start the variable names with hyphens because # they can't be bind variables. variable -set {*}{ -columns -db -needcolumns -resultDict -results -sql -Cursor -RowCount -END } constructor {statement args} { next set -db [$statement getDBhandle] set -sql [$statement getSql] set -columns [list] set -results [list] set -resultDict [dict create] ${-db} trace [namespace code {my RecordStatement}] if {[llength $args] == 0} { # Variable substitutions are evaluated in caller's context uplevel 1 [list ${-db} eval -withoutnulls -asdict ${-sql} \ [namespace which -variable -resultDict] \ [namespace code {my RecordResult}]] } elseif {[llength $args] == 1} { # Variable substitutions are in the dictionary at [lindex $args 0]. set -paramDict [lindex $args 0] # At this point, the activation record must contain no variables # that might be bound within the query. All variables at this point # begin with hyphens so that they are syntactically incorrect # as bound variables in SQL. unset args unset statement dict with -paramDict { ${-db} eval -withoutnulls -asdict ${-sql} -resultDict { my RecordResult } } } else { ${-db} trace {} |
︙ | ︙ | |||
597 598 599 600 601 602 603 | } # Record one row of results from a query by appending it as a dictionary # to the 'results' list. As a side effect, set 'columns' to a list # comprising the names of the columns of the result. method RecordResult {} { | < > > > > | < < < < | > | | | 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 | } # Record one row of results from a query by appending it as a dictionary # to the 'results' list. As a side effect, set 'columns' to a list # comprising the names of the columns of the result. method RecordResult {} { if {[info exists -needcolumns]} { set columns [dict get ${-resultDict} *] lappend -results columns $columns unset -needcolumns foreach key [dict keys ${-resultDict}] { if {$key ni $columns} { set -resultDict [dict remove ${-resultDict} $key] } } } lappend -results row ${-resultDict} set -resultDict [dict create] } # Advance to the next result set method nextresults {} { set have 0 while {${-Cursor} < [llength ${-results}]} { if {[lindex ${-results} ${-Cursor}] eq {statement}} { set have 1 incr -Cursor 2 break } incr -Cursor 2 } if {!$have} { set -END {} } if {${-Cursor} >= [llength ${-results}]} { set -columns [list] } elseif {[lindex ${-results} ${-Cursor}] eq {columns}} { incr -Cursor set -columns [lindex ${-results} ${-Cursor}] incr -Cursor } else { set -columns [list] } return $have } method getDBhandle {} { return ${-db} } |
︙ | ︙ |