diff options
| author | 2021-10-23 15:47:02 +0200 | |
|---|---|---|
| committer | 2021-10-23 16:48:06 +0200 | |
| commit | 4728ef52fa0afb9bab2d577a2187f38a3d4bc73d (patch) | |
| tree | 6decf92df2745c718fdad4746470c00240e67c8c /query.zig | |
| parent | query: increase eval branch quota for tests (diff) | |
| download | zig-sqlite-4728ef52fa0afb9bab2d577a2187f38a3d4bc73d.tar.gz zig-sqlite-4728ef52fa0afb9bab2d577a2187f38a3d4bc73d.tar.xz zig-sqlite-4728ef52fa0afb9bab2d577a2187f38a3d4bc73d.zip | |
query: use lowercase for enum fields
Diffstat (limited to 'query.zig')
| -rw-r--r-- | query.zig | 21 |
1 files changed, 12 insertions, 9 deletions
| @@ -14,14 +14,17 @@ const BindMarker = struct { | |||
| 14 | /// A null means the bind parameter is untyped so there won't be comptime checking. | 14 | /// A null means the bind parameter is untyped so there won't be comptime checking. |
| 15 | typed: ?type = null, | 15 | typed: ?type = null, |
| 16 | 16 | ||
| 17 | // TODO(vincent): both identifier and identifier_type are unused outside of parsing them. | ||
| 18 | // Should we remove them ? | ||
| 19 | |||
| 17 | /// Contains the bind parameter identifier string. | 20 | /// Contains the bind parameter identifier string. |
| 18 | identifier: ?[]const u8 = null, | 21 | identifier: ?[]const u8 = null, |
| 19 | /// Contains the type of the identifier which is either an integer or a string. | 22 | /// Contains the type of the identifier which is either an integer or a string. |
| 20 | identifier_type: IdentifierType = .Integer, | 23 | identifier_type: IdentifierType = .integer, |
| 21 | 24 | ||
| 22 | pub const IdentifierType = enum { | 25 | pub const IdentifierType = enum { |
| 23 | Integer, | 26 | integer, |
| 24 | String, | 27 | string, |
| 25 | }; | 28 | }; |
| 26 | }; | 29 | }; |
| 27 | 30 | ||
| @@ -55,7 +58,7 @@ pub const ParsedQuery = struct { | |||
| 55 | parsed_query.bind_markers[parsed_query.nb_bind_markers] = BindMarker{}; | 58 | parsed_query.bind_markers[parsed_query.nb_bind_markers] = BindMarker{}; |
| 56 | current_bind_marker_type_pos = 0; | 59 | current_bind_marker_type_pos = 0; |
| 57 | current_bind_marker_id_pos = 0; | 60 | current_bind_marker_id_pos = 0; |
| 58 | parsed_query.bind_markers[parsed_query.nb_bind_markers].identifier_type = if (c == '?') .Integer else .String; | 61 | parsed_query.bind_markers[parsed_query.nb_bind_markers].identifier_type = if (c == '?') .integer else .string; |
| 59 | state = .BindMarker; | 62 | state = .BindMarker; |
| 60 | buf[pos] = c; | 63 | buf[pos] = c; |
| 61 | pos += 1; | 64 | pos += 1; |
| @@ -326,19 +329,19 @@ test "parsed query: bind markers identifier type" { | |||
| 326 | 329 | ||
| 327 | const testCases = &[_]testCase{ .{ | 330 | const testCases = &[_]testCase{ .{ |
| 328 | .query = "foobar @ABC{usize}", | 331 | .query = "foobar @ABC{usize}", |
| 329 | .expected_marker = .{ .identifier_type = .String }, | 332 | .expected_marker = .{ .identifier_type = .string }, |
| 330 | }, .{ | 333 | }, .{ |
| 331 | .query = "foobar ?123{text}", | 334 | .query = "foobar ?123{text}", |
| 332 | .expected_marker = .{ .identifier_type = .Integer }, | 335 | .expected_marker = .{ .identifier_type = .integer }, |
| 333 | }, .{ | 336 | }, .{ |
| 334 | .query = "foobar $abc{blob}", | 337 | .query = "foobar $abc{blob}", |
| 335 | .expected_marker = .{ .identifier_type = .String }, | 338 | .expected_marker = .{ .identifier_type = .string }, |
| 336 | }, .{ | 339 | }, .{ |
| 337 | .query = "foobar ?123", | 340 | .query = "foobar ?123", |
| 338 | .expected_marker = .{ .identifier_type = .Integer }, | 341 | .expected_marker = .{ .identifier_type = .integer }, |
| 339 | }, .{ | 342 | }, .{ |
| 340 | .query = "foobar :abc", | 343 | .query = "foobar :abc", |
| 341 | .expected_marker = .{ .identifier_type = .String }, | 344 | .expected_marker = .{ .identifier_type = .string }, |
| 342 | } }; | 345 | } }; |
| 343 | 346 | ||
| 344 | inline for (testCases) |tc| { | 347 | inline for (testCases) |tc| { |