TestIntervalColumnType tests INTERVAL support as both a column type and expression
(t *testing.T)
| 105 | |
| 106 | // TestIntervalColumnType tests INTERVAL support as both a column type and expression |
| 107 | func TestIntervalColumnType(t *testing.T) { |
| 108 | testCases := []struct { |
| 109 | name string |
| 110 | sql string |
| 111 | shouldParse bool |
| 112 | description string |
| 113 | }{ |
| 114 | // INTERVAL as column type tests |
| 115 | { |
| 116 | name: "INTERVAL as simple column type", |
| 117 | sql: "CREATE TABLE events (duration INTERVAL)", |
| 118 | shouldParse: true, |
| 119 | description: "INTERVAL should work as a basic column type", |
| 120 | }, |
| 121 | { |
| 122 | name: "INTERVAL with precision", |
| 123 | sql: "CREATE TABLE events (duration INTERVAL(6))", |
| 124 | shouldParse: true, |
| 125 | description: "INTERVAL should accept optional precision", |
| 126 | }, |
| 127 | { |
| 128 | name: "INTERVAL with NOT NULL constraint", |
| 129 | sql: "CREATE TABLE events (duration INTERVAL NOT NULL)", |
| 130 | shouldParse: true, |
| 131 | description: "INTERVAL columns should support constraints", |
| 132 | }, |
| 133 | { |
| 134 | name: "Multiple INTERVAL columns", |
| 135 | sql: "CREATE TABLE events (start_time INTERVAL, end_time INTERVAL NOT NULL, break_time INTERVAL DEFAULT '15 minutes')", |
| 136 | shouldParse: true, |
| 137 | description: "Should support multiple INTERVAL columns with various options", |
| 138 | }, |
| 139 | { |
| 140 | name: "INTERVAL with DEFAULT string literal", |
| 141 | sql: "CREATE TABLE events (break_time INTERVAL DEFAULT '15 minutes')", |
| 142 | shouldParse: true, |
| 143 | description: "INTERVAL should support DEFAULT with string literals", |
| 144 | }, |
| 145 | { |
| 146 | name: "INTERVAL with type cast in DEFAULT", |
| 147 | sql: "CREATE TABLE events (break_time VARCHAR(50) DEFAULT '1 day'::interval)", |
| 148 | shouldParse: true, |
| 149 | description: "Should support casting to INTERVAL in DEFAULT expressions", |
| 150 | }, |
| 151 | { |
| 152 | name: "ALTER TABLE ADD INTERVAL column", |
| 153 | sql: "ALTER TABLE events ADD break_time INTERVAL", |
| 154 | shouldParse: false, // ALTER TABLE ADD COLUMN not yet implemented in parser |
| 155 | description: "ALTER TABLE ADD COLUMN syntax not yet supported (separate from INTERVAL feature)", |
| 156 | }, |
| 157 | { |
| 158 | name: "CREATE INDEX on INTERVAL column", |
| 159 | sql: "CREATE INDEX idx_duration ON events (duration)", |
| 160 | shouldParse: true, |
| 161 | description: "Should be able to create indexes on INTERVAL columns", |
| 162 | }, |
| 163 | // Type casting tests |
| 164 | { |