Now query with relationship will write the UUID bytes betwen {|<>|}

So then I can parse the file again, create a map of UUID sub json and
just iterate over the first json looking for UUID and update with new
data from map
This commit is contained in:
2024-12-20 22:29:02 +01:00
parent 7fb0b5f63e
commit e7056efec9
4 changed files with 77 additions and 10 deletions
+3 -1
View File
@@ -9,6 +9,8 @@ const UUID = dtype.UUID;
const ZipponError = @import("stuffs/errors.zig").ZipponError;
// TODO: Try std.json
pub const EntityWriter = struct {
pub fn writeEntityTable(
writer: anytype,
@@ -47,7 +49,7 @@ pub const EntityWriter = struct {
.UUID => |v| {
const uuid = try UUID.parse("00000000-0000-0000-0000-000000000000"); // Maybe pass that comptime to prevent parsing it everytime
if (!std.meta.eql(v, uuid.bytes)) {
try writer.print("\"{s}\"", .{UUID.format_bytes(v)});
try writer.print("\"{{|<{s}>|}}\"", .{v});
} else {
try writer.print("{{}}", .{});
}
-3
View File
@@ -456,7 +456,6 @@ pub const FileEngine = struct {
data_types: []const DataType,
sync_context: *ThreadSyncContext,
) void {
log.debug("{any}\n", .{@TypeOf(writer)});
var data_buffer: [BUFFER_SIZE]u8 = undefined;
var fa = std.heap.FixedBufferAllocator.init(&data_buffer);
defer fa.reset();
@@ -513,8 +512,6 @@ pub const FileEngine = struct {
const path = std.fmt.bufPrint(&path_buffer, "{s}/DATA/{s}/{d}.zid", .{ self.path_to_ZipponDB_dir, struct_name, file_index }) catch return FileEngineError.MemoryError;
const data = try self.orderedNewData(allocator, struct_name, map);
std.debug.print("{any}", .{data});
var data_writer = zid.DataWriter.init(path, null) catch return FileEngineError.ZipponDataError;
defer data_writer.deinit();
+16 -5
View File
@@ -797,7 +797,6 @@ pub const Parser = struct {
.expect_new_value => {
const data_type = self.schema_engine.memberName2DataType(struct_name, member_name) catch return ZiQlParserError.StructNotFound;
std.debug.print("DATA TYPE: {any}\n", .{data_type});
map.put(member_name, try self.parseConditionValue(allocator, struct_name, data_type, &token)) catch return ZipponError.MemoryError;
if (data_type == .link or data_type == .link_array) {
token = self.toker.last_token;
@@ -1060,6 +1059,8 @@ pub const Parser = struct {
}
};
// TODO: Check if what is send is expected
test "ADD" {
try testParsing("ADD User (name = 'Bob', email='bob@email.com', age=55, scores=[ 1 ], best_friend=none, friends=none, bday=2000/01/01, a_time=12:04, last_order=2000/01/01-12:45)");
try testParsing("ADD User (name = 'Bob', email='bob@email.com', age=55, scores=[ 666 123 331 ], best_friend=none, friends=none, bday=2000/11/01, a_time=12:04:54, last_order=2000/01/01-12:45)");
@@ -1110,19 +1111,29 @@ test "Specific query" {
try testParsing("GRAB User [1]");
}
// TODO: next step is to make this work
// FIXME: This make the following query return only 1 thing, to check
test "UPDATE relationship" {
try testParsing("UPDATE User [1] {name='Bob'} TO (best_friend = {name='Boba'} )");
try testParsing("GRAB User {}");
}
// Not yet working but dont trow an error
test "GRAB Relationship" {
// WORKING!!!!
test "GRAB Relationship Filter" {
try testParsing("GRAB User {best_friend IN {name = 'Bob'}}");
try testParsing("GRAB User {best_friend IN {name = 'Boba'}}");
}
// Make work
test "GRAB Relationship AdditionalData" {
try testParsing("GRAB User [name, friends] {}");
try testParsing("GRAB User [name, best_friend] {}");
try testParsing("GRAB User [2; name, best_friend] {best_friend != none}");
}
test "GRAB Relationship dot" {
try testParsing("GRAB User.best_friend {}");
}
test "DELETE" {
try testParsing("DELETE User {}");
}