-
-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some small tweaks to Red. #404
Open
xinminglai
wants to merge
8
commits into
FCO:master
Choose a base branch
from
xinminglai:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7b1420b
Add column-values method to MetamodelX::Red::Model
xinminglai 3cdb36b
Additional types text/json/jsonb info for Driver::Pg
xinminglai 18038bf
Fix In operation for Driver::Pg
xinminglai c61a81c
Merge remote-tracking branch 'fco/master'
xinminglai 8e1055f
Merge remote-tracking branch 'fco/master'
xinminglai cd6984a
Use self.wildcard to implement the In with @array values.
xinminglai 34c2096
$data structure fix for Postgres, so it behave consistently with SQLite
xinminglai d3b0cab
Use data-copy to prevent modify of immutable exception.
xinminglai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use Red; | ||
use Test; | ||
|
||
my $*RED-PG-TEST-DB = $_ with %*ENV<RED_PG_TEST_DB>; | ||
|
||
my $*RED-DEBUG = $_ with %*ENV<RED_DEBUG>; | ||
my $*RED-DEBUG-AST = $_ with %*ENV<RED_DEBUG_AST>; | ||
|
||
plan 2; | ||
unless $*RED-PG-TEST-DB { | ||
"No RED_PG_TEST_DB initialized.".say; | ||
skip-rest 2; | ||
} | ||
|
||
model Category is table<test_category> { | ||
has Int $.id is serial; | ||
has Int $.parent_id is column{ :references{ Category.id }, :nullable, }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test is failing here. For has Int $.parent_if is column{ :references{ .id }, :nullable }; |
||
has Str $.name is column; | ||
|
||
has Category $.parent is relationship{ .parent_id }; | ||
has Category @.children is relationship{ .parent_id }; | ||
} | ||
|
||
$GLOBAL::RED-DB = database "Pg", :dbname($*RED-PG-TEST-DB); | ||
|
||
Category.^create-table; | ||
|
||
my $parent = Category.^create: :name('xx'); | ||
|
||
for [1 .. 5] -> $x { | ||
Category.^create: :parent_id($parent.id), :name("child-$x"); | ||
} | ||
|
||
# # This worked. | ||
# (Category.^rs.grep: { .id (<) Category.^all.grep({ .id == 3 }).map({ .id }) } ).Seq.perl.say; | ||
|
||
# # This doesn't. | ||
# (Category.^rs.grep: { .id (<) $parent.children.map({ .id }) } ).Seq.perl.say; | ||
|
||
|
||
|
||
# This worked in SQLite (But doesn't work with Pg driver.) | ||
# my $*RED-DEBUG-AST = True; | ||
my @seq = $parent.children.map({ .id }).Seq.sort; | ||
|
||
is-deeply @seq, [Category.^rs.grep({ .id in @seq }).map(*.id).Seq.sort], "in with literal list for pg"; | ||
is-deeply @seq, [Category.^rs.grep({ .id (<) @seq }).map(*.id).Seq.sort], "in with literal list for pg (<) operator"; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you, please, add a test for json and jsonb?