tkt3992.test 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # 2001 September 15
  2. #
  3. # The author disclaims copyright to this source code. In place of
  4. # 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. # $Id: tkt3992.test,v 1.1 2009/07/27 10:05:06 danielk1977 Exp $
  13. set testdir [file dirname $argv0]
  14. source $testdir/tester.tcl
  15. do_test tkt3992-1.1 {
  16. execsql {
  17. CREATE TABLE parameters1(
  18. mountcnt INT NOT NULL CHECK (typeof(mountcnt) == 'integer'),
  19. version REAL NOT NULL
  20. );
  21. INSERT INTO parameters1(mountcnt, version) VALUES(1, 1.0);
  22. CREATE TABLE parameters2(
  23. mountcnt INT NOT NULL CHECK (typeof(mountcnt) == 'integer'),
  24. version REAL CHECK (typeof(version) == 'real')
  25. );
  26. INSERT INTO parameters2(mountcnt, version) VALUES(1, 1.0);
  27. }
  28. } {}
  29. do_test tkt3992-1.2 {
  30. execsql {
  31. UPDATE parameters1 SET mountcnt = mountcnt + 1;
  32. SELECT * FROM parameters1;
  33. }
  34. } {2 1.0}
  35. do_test tkt3992-1.3 {
  36. execsql {
  37. UPDATE parameters2 SET mountcnt = mountcnt + 1;
  38. SELECT * FROM parameters2;
  39. }
  40. } {2 1.0}
  41. ifcapable altertable {
  42. do_test tkt3992-2.1 {
  43. execsql {
  44. CREATE TABLE t1(a, b);
  45. INSERT INTO t1 VALUES(1, 2);
  46. ALTER TABLE t1 ADD COLUMN c DEFAULT 3;
  47. SELECT * FROM t1;
  48. }
  49. } {1 2 3}
  50. do_test tkt3992-2.2 {
  51. execsql {
  52. UPDATE t1 SET a = 'one';
  53. SELECT * FROM t1;
  54. }
  55. } {one 2 3}
  56. }
  57. ifcapable trigger {
  58. db function tcl eval
  59. do_test tkt3992-2.3 {
  60. execsql {
  61. CREATE TABLE t2(a REAL, b REAL, c REAL);
  62. INSERT INTO t2 VALUES(1, 2, 3);
  63. CREATE TRIGGER tr2 BEFORE UPDATE ON t2 BEGIN
  64. SELECT tcl('set res', typeof(new.c));
  65. END;
  66. UPDATE t2 SET a = 'I';
  67. }
  68. set res
  69. } {real}
  70. }
  71. finish_test