default.test 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # 2005 August 18
  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. # This file implements regression tests for SQLite library. The
  12. # focus of this file is testing corner cases of the DEFAULT syntax
  13. # on table definitions.
  14. #
  15. # $Id: default.test,v 1.3 2009/02/19 14:39:25 danielk1977 Exp $
  16. #
  17. set testdir [file dirname $argv0]
  18. source $testdir/tester.tcl
  19. ifcapable bloblit {
  20. do_test default-1.1 {
  21. execsql {
  22. CREATE TABLE t1(
  23. a INTEGER,
  24. b BLOB DEFAULT x'6869'
  25. );
  26. INSERT INTO t1(a) VALUES(1);
  27. SELECT * from t1;
  28. }
  29. } {1 hi}
  30. }
  31. do_test default-1.2 {
  32. execsql {
  33. CREATE TABLE t2(
  34. x INTEGER,
  35. y INTEGER DEFAULT NULL
  36. );
  37. INSERT INTO t2(x) VALUES(1);
  38. SELECT * FROM t2;
  39. }
  40. } {1 {}}
  41. do_test default-1.3 {
  42. catchsql {
  43. CREATE TABLE t3(
  44. x INTEGER,
  45. y INTEGER DEFAULT (max(x,5))
  46. )
  47. }
  48. } {1 {default value of column [y] is not constant}}
  49. ifcapable pragma {
  50. do_test default-2.1 {
  51. execsql {
  52. CREATE TABLE t4(c DEFAULT 'abc');
  53. PRAGMA table_info(t4);
  54. }
  55. } {0 c {} 0 'abc' 0}
  56. do_test default-2.2 {
  57. execsql {
  58. INSERT INTO t4 DEFAULT VALUES;
  59. PRAGMA table_info(t4);
  60. }
  61. } {0 c {} 0 'abc' 0}
  62. }
  63. finish_test