diff options
| author | 2021-10-23 14:17:36 +0200 | |
|---|---|---|
| committer | 2021-10-23 16:48:06 +0200 | |
| commit | 3218c1fabb9d1ed7d7bf098a21dd53a02c353664 (patch) | |
| tree | fbd3d68ff7140aba2174f8684008b76a6b658027 | |
| parent | query.zig: code format (diff) | |
| download | zig-sqlite-3218c1fabb9d1ed7d7bf098a21dd53a02c353664.tar.gz zig-sqlite-3218c1fabb9d1ed7d7bf098a21dd53a02c353664.tar.xz zig-sqlite-3218c1fabb9d1ed7d7bf098a21dd53a02c353664.zip | |
rename id_type/IdType for naming consistency
| -rw-r--r-- | query.zig | 18 |
1 files changed, 9 insertions, 9 deletions
| @@ -10,9 +10,9 @@ pub const Text = struct { data: []const u8 }; | |||
| 10 | const BindMarker = struct { | 10 | const BindMarker = struct { |
| 11 | typed: ?type = null, // null == untyped | 11 | typed: ?type = null, // null == untyped |
| 12 | identifier: ?[]const u8 = null, | 12 | identifier: ?[]const u8 = null, |
| 13 | id_type: IdType = .Integer, | 13 | identifier_type: IdentifierType = .Integer, |
| 14 | 14 | ||
| 15 | pub const IdType = enum { | 15 | pub const IdentifierType = enum { |
| 16 | Integer, | 16 | Integer, |
| 17 | String, | 17 | String, |
| 18 | }; | 18 | }; |
| @@ -48,7 +48,7 @@ pub const ParsedQuery = struct { | |||
| 48 | parsed_query.bind_markers[parsed_query.nb_bind_markers] = BindMarker{}; | 48 | parsed_query.bind_markers[parsed_query.nb_bind_markers] = BindMarker{}; |
| 49 | current_bind_marker_type_pos = 0; | 49 | current_bind_marker_type_pos = 0; |
| 50 | current_bind_marker_id_pos = 0; | 50 | current_bind_marker_id_pos = 0; |
| 51 | parsed_query.bind_markers[parsed_query.nb_bind_markers].id_type = if (c == '?') .Integer else .String; | 51 | parsed_query.bind_markers[parsed_query.nb_bind_markers].identifier_type = if (c == '?') .Integer else .String; |
| 52 | state = .BindMarker; | 52 | state = .BindMarker; |
| 53 | buf[pos] = c; | 53 | buf[pos] = c; |
| 54 | pos += 1; | 54 | pos += 1; |
| @@ -315,19 +315,19 @@ test "parsed query: bind markers identifier type" { | |||
| 315 | 315 | ||
| 316 | const testCases = &[_]testCase{ .{ | 316 | const testCases = &[_]testCase{ .{ |
| 317 | .query = "foobar @ABC{usize}", | 317 | .query = "foobar @ABC{usize}", |
| 318 | .expected_marker = .{ .id_type = .String }, | 318 | .expected_marker = .{ .identifier_type = .String }, |
| 319 | }, .{ | 319 | }, .{ |
| 320 | .query = "foobar ?123{text}", | 320 | .query = "foobar ?123{text}", |
| 321 | .expected_marker = .{ .id_type = .Integer }, | 321 | .expected_marker = .{ .identifier_type = .Integer }, |
| 322 | }, .{ | 322 | }, .{ |
| 323 | .query = "foobar $abc{blob}", | 323 | .query = "foobar $abc{blob}", |
| 324 | .expected_marker = .{ .id_type = .String }, | 324 | .expected_marker = .{ .identifier_type = .String }, |
| 325 | }, .{ | 325 | }, .{ |
| 326 | .query = "foobar ?123", | 326 | .query = "foobar ?123", |
| 327 | .expected_marker = .{ .id_type = .Integer }, | 327 | .expected_marker = .{ .identifier_type = .Integer }, |
| 328 | }, .{ | 328 | }, .{ |
| 329 | .query = "foobar :abc", | 329 | .query = "foobar :abc", |
| 330 | .expected_marker = .{ .id_type = .String }, | 330 | .expected_marker = .{ .identifier_type = .String }, |
| 331 | } }; | 331 | } }; |
| 332 | 332 | ||
| 333 | inline for (testCases) |tc| { | 333 | inline for (testCases) |tc| { |
| @@ -336,6 +336,6 @@ test "parsed query: bind markers identifier type" { | |||
| 336 | try testing.expectEqual(@as(usize, 1), parsed_query.nb_bind_markers); | 336 | try testing.expectEqual(@as(usize, 1), parsed_query.nb_bind_markers); |
| 337 | 337 | ||
| 338 | const bind_marker = parsed_query.bind_markers[0]; | 338 | const bind_marker = parsed_query.bind_markers[0]; |
| 339 | try testing.expectEqual(tc.expected_marker.id_type, bind_marker.id_type); | 339 | try testing.expectEqual(tc.expected_marker.identifier_type, bind_marker.identifier_type); |
| 340 | } | 340 | } |
| 341 | } | 341 | } |