diff options
| author | 2021-06-25 18:17:55 +0200 | |
|---|---|---|
| committer | 2021-06-25 18:17:55 +0200 | |
| commit | e4605052768e757586c7012f5d85dd5f8aa6c83c (patch) | |
| tree | af17aff29b81c3934818c99aa1b6bc64e11f737d | |
| parent | fix 'redundant comptile' error (diff) | |
| download | zig-sqlite-e4605052768e757586c7012f5d85dd5f8aa6c83c.tar.gz zig-sqlite-e4605052768e757586c7012f5d85dd5f8aa6c83c.tar.xz zig-sqlite-e4605052768e757586c7012f5d85dd5f8aa6c83c.zip | |
query: fix new compilation errors
Diffstat (limited to '')
| -rw-r--r-- | query.zig | 12 |
1 files changed, 3 insertions, 9 deletions
| @@ -22,12 +22,6 @@ pub const ParsedQuery = struct { | |||
| 22 | query_size: usize, | 22 | query_size: usize, |
| 23 | 23 | ||
| 24 | pub fn from(comptime query: []const u8) Self { | 24 | pub fn from(comptime query: []const u8) Self { |
| 25 | const State = enum { | ||
| 26 | Start, | ||
| 27 | BindMarker, | ||
| 28 | BindMarkerType, | ||
| 29 | }; | ||
| 30 | |||
| 31 | comptime var buf: [query.len]u8 = undefined; | 25 | comptime var buf: [query.len]u8 = undefined; |
| 32 | comptime var pos = 0; | 26 | comptime var pos = 0; |
| 33 | comptime var state = .Start; | 27 | comptime var state = .Start; |
| @@ -38,7 +32,7 @@ pub const ParsedQuery = struct { | |||
| 38 | comptime var parsed_query: ParsedQuery = undefined; | 32 | comptime var parsed_query: ParsedQuery = undefined; |
| 39 | parsed_query.nb_bind_markers = 0; | 33 | parsed_query.nb_bind_markers = 0; |
| 40 | 34 | ||
| 41 | inline for (query) |c, i| { | 35 | inline for (query) |c| { |
| 42 | switch (state) { | 36 | switch (state) { |
| 43 | .Start => switch (c) { | 37 | .Start => switch (c) { |
| 44 | '?' => { | 38 | '?' => { |
| @@ -71,7 +65,7 @@ pub const ParsedQuery = struct { | |||
| 71 | '}' => { | 65 | '}' => { |
| 72 | state = .Start; | 66 | state = .Start; |
| 73 | 67 | ||
| 74 | const typ = parsed_query.parseType(current_bind_marker_type[0..current_bind_marker_type_pos]); | 68 | const typ = parseType(current_bind_marker_type[0..current_bind_marker_type_pos]); |
| 75 | 69 | ||
| 76 | parsed_query.bind_markers[parsed_query.nb_bind_markers] = BindMarker{ .Typed = typ }; | 70 | parsed_query.bind_markers[parsed_query.nb_bind_markers] = BindMarker{ .Typed = typ }; |
| 77 | parsed_query.nb_bind_markers += 1; | 71 | parsed_query.nb_bind_markers += 1; |
| @@ -103,7 +97,7 @@ pub const ParsedQuery = struct { | |||
| 103 | return parsed_query; | 97 | return parsed_query; |
| 104 | } | 98 | } |
| 105 | 99 | ||
| 106 | fn parseType(comptime self: *Self, type_info: []const u8) type { | 100 | fn parseType(type_info: []const u8) type { |
| 107 | if (type_info.len <= 0) @compileError("invalid type info " ++ type_info); | 101 | if (type_info.len <= 0) @compileError("invalid type info " ++ type_info); |
| 108 | 102 | ||
| 109 | // Integer | 103 | // Integer |