CoolFace
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
bind2.test64 linesDownload Raw Back to test
1# 2022 Feb 102#3# The author disclaims copyright to this source code.  In place of4# a legal notice, here is a blessing:5#6#    May you do good and not evil.7#    May you find forgiveness for yourself and forgive others.8#    May you share freely, never taking more than you give.9#10#***********************************************************************11#12 13set testdir [file dirname $argv0]14source $testdir/tester.tcl15set testprefix bind216 17 18# Test that using bind_value() on a REAL sqlite3_value that was stored19# as an INTEGER works properly.20#21#   1.1: An IntReal value read from a table,22#   1.2: IntReal values obtained via the sqlite3_preupdate_old|new() 23#        interfaces.24# 25do_execsql_test 1.0 { 26  CREATE TABLE t1(a REAL);27  INSERT INTO t1 VALUES(42.0);28  SELECT * FROM t1;29} {42.0}30 31do_test 1.1 {32  set stmt [sqlite3_prepare db "SELECT ?" -1 tail]33  sqlite3_bind_value_from_select $stmt 1 "SELECT a FROM t1"34  sqlite3_step $stmt35  sqlite3_column_text $stmt 036} {42.0}37sqlite3_finalize $stmt38 39ifcapable !preupdate {40  finish_test41  return42}43 44proc preup {args} {45  set stmt [sqlite3_prepare db "SELECT ?" -1 tail]46  sqlite3_bind_value_from_preupdate $stmt 1 old 047  sqlite3_step $stmt48  lappend ::reslist [sqlite3_column_text $stmt 0]49  sqlite3_reset $stmt50  sqlite3_bind_value_from_preupdate $stmt 1 new 051  sqlite3_step $stmt52  lappend ::reslist [sqlite3_column_text $stmt 0]53  sqlite3_finalize $stmt54}55db preupdate hook preup56 57do_test 1.2 {58  set ::reslist [list]59  execsql { UPDATE t1 SET a=43; }60  set ::reslist61} {42.0 43.0}62 63finish_test64