Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@
*.db
tags
.racoco
zef/
*.sqlite3
8 changes: 4 additions & 4 deletions lib/Red/Driver/Pg.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ submethod TWEAK() {
;
}

# JSON values are stringified when binding/reading
method stringify-json { True }
# JSON values are passed as native structures to DBIish
method stringify-json { False }

method new-connection($dbh = $!dbh) { self.clone: dbh => $dbh }

Expand Down Expand Up @@ -148,13 +148,13 @@ multi method pg-jsonb-path-item(Str $_) { $_ }
multi method translate(Red::AST::JsonItem $_, $context?) {
my ($left, @lb) := do given self.translate: .left, $context { .key, .value };
my $path = self.pg-jsonb-path-item: .right.value;
"($left #> '{ $path }')" => @lb
"($left #> '\{$path\}')" => @lb
}

multi method translate(Red::AST::JsonRemoveItem $_, $context?) {
my ($left, @lb) := do given self.translate: .left, $context { .key, .value };
my $path = self.pg-jsonb-path-item: .right.value;
"($left #- '{ $path }')" => @lb
"($left #- '\{$path\}')" => @lb
}

multi method translate(Red::AST::Value $_ where { .type ~~ Pair and .value.key ~~ Red::AST::JsonItem }, "update") {
Expand Down
2 changes: 1 addition & 1 deletion lib/Red/Type/Json.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ method deflator {
-> $data {
# TODO: Find a better way of doing this
do if get-RED-DB.?stringify-json {
try { to-json $data } // $data
try { to-json $data, :!pretty } // $data
} else {
$data
}
Expand Down
1 change: 0 additions & 1 deletion t/14-union.rakutest
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ isa-ok $intersect2, M::ResultSeq;
isa-ok $intersect2.ast, Red::AST::Intersect;
is-deeply $intersect2.map(*.a).Seq.sort, eager 10 ^..^ 20;

skip-rest("Pg do not accept minus"), exit with %*ENV<RED_DATABASE>;
my $minus1 = M.^all (-) M.^all.grep(*.a >= 20);
isa-ok $minus1, M::ResultSeq;
isa-ok $minus1.ast, Red::AST::Minus;
Expand Down
Loading