-
Notifications
You must be signed in to change notification settings - Fork 79
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
columns filtering #15
Conversation
end | ||
end | ||
end | ||
|
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.
Style/TrailingBlankLines: 1 trailing blank lines detected.
.to include("rating" => 22) | ||
|
||
expect(post.log_data.versions.first.changes) | ||
.not_to include("title" => "Triggers", "active" => true) |
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.
Style/DotPosition: Place the . on the previous line, together with the method call receiver.
Style/MultilineMethodCallIndentation: Use 2 (not 4) spaces for indenting an expression spanning multiple lines.
expect(post.reload.log_version).to eq 6 | ||
expect(post.log_size).to eq 4 | ||
expect(post.log_data.versions.first.changes) | ||
.to include("rating" => 22) |
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.
Style/DotPosition: Place the . on the previous line, together with the method call receiver.
Style/MultilineMethodCallIndentation: Use 2 (not 4) spaces for indenting an expression spanning multiple lines.
.to include("rating" => 10) | ||
|
||
expect(post.log_data.versions.first.changes) | ||
.not_to include("title" => "Triggers", "active" => true) |
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.
Style/DotPosition: Place the . on the previous line, together with the method call receiver.
Style/MultilineMethodCallIndentation: Use 2 (not 4) spaces for indenting an expression spanning multiple lines.
expect(post.reload.log_version).to eq 5 | ||
expect(post.log_size).to eq 4 | ||
expect(post.log_data.versions.first.changes) | ||
.to include("rating" => 10) |
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.
Style/DotPosition: Place the . on the previous line, together with the method call receiver.
Style/MultilineMethodCallIndentation: Use 2 (not 4) spaces for indenting an expression spanning multiple lines.
.to include("title" => "Triggers", "active" => true) | ||
|
||
expect(post.log_data.versions.first.changes) | ||
.not_to include("rating" => 20) |
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.
Style/DotPosition: Place the . on the previous line, together with the method call receiver.
Style/MultilineMethodCallIndentation: Use 2 (not 4) spaces for indenting an expression spanning multiple lines.
expect(post.reload.log_version).to eq 6 | ||
expect(post.log_size).to eq 4 | ||
expect(post.log_data.versions.first.changes) | ||
.to include("title" => "Triggers", "active" => true) |
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.
Style/DotPosition: Place the . on the previous line, together with the method call receiver.
Style/MultilineMethodCallIndentation: Use 2 (not 4) spaces for indenting an expression spanning multiple lines.
.to include("title" => "Triggers", "active" => true) | ||
|
||
expect(post.log_data.versions.first.changes) | ||
.not_to include("rating" => 10) |
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.
Style/DotPosition: Place the . on the previous line, together with the method call receiver.
Style/MultilineMethodCallIndentation: Use 2 (not 4) spaces for indenting an expression spanning multiple lines.
expect(post.reload.log_version).to eq 5 | ||
expect(post.log_size).to eq 4 | ||
expect(post.log_data.versions.first.changes) | ||
.to include("title" => "Triggers", "active" => true) |
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.
Style/DotPosition: Place the . on the previous line, together with the method call receiver.
Style/MultilineMethodCallIndentation: Use 2 (not 4) spaces for indenting an expression spanning multiple lines.
let(:args) { ["user", "--except='active,age'", "--only='active,age'"] } | ||
|
||
it "creates trigger with except and only" do | ||
is_expected.to exist |
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.
Style/IndentationWidth: Use 2 (not 4) spaces for indentation.
end | ||
|
||
context "with except and only" do | ||
let(:args) { ["user", "--except='active,age'", "--only='active,age'"] } |
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.
Style/IndentationWidth: Use 2 (not 4) spaces for indentation.
let(:args) { ["user", "--limit=5", "--except='active,age'", "--only='active,age'"] } | ||
|
||
it "creates trigger with limit and except and only" do | ||
is_expected.to exist |
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.
Style/IndentationWidth: Use 2 (not 4) spaces for indentation.
end | ||
|
||
context "with limit and except and only" do | ||
let(:args) { ["user", "--limit=5", "--except='active,age'", "--only='active,age'"] } |
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.
Style/IndentationWidth: Use 2 (not 4) spaces for indentation.
let(:args) { ["user", "--limit=5", "--only='active,age'"] } | ||
|
||
it "creates trigger with limit and only" do | ||
is_expected.to exist |
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.
Style/IndentationWidth: Use 2 (not 4) spaces for indentation.
end | ||
|
||
context "with limit and only" do | ||
let(:args) { ["user", "--limit=5", "--only='active,age'"] } |
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.
Style/IndentationWidth: Use 2 (not 4) spaces for indentation.
let(:args) { ["user", "--limit=5", "--except='active,age'"] } | ||
|
||
it "creates trigger with limit and except" do | ||
is_expected.to exist |
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.
Style/IndentationWidth: Use 2 (not 4) spaces for indentation.
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.
Overall, great work! Thanks!
IF blacklist <> 'null' THEN | ||
filtered_array := logidze_exclude_keys(data, array['log_data']::text[] || string_to_array(blacklist, ',')); | ||
ELSIF blacklist = 'null' AND whitelist <> 'null' THEN | ||
filtered_array := logidze_include_keys(data, string_to_array(whitelist, ',')); |
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.
I'd prefer to leave the only one function for filtering, logidze_exclude_keys
.
Then we have to calculate required keys beforehand, smth like:
keys_to_exclude := select array(select unnest(jsonb_object_keys(data)) except select unnest(whitelist));
filtered_array := logidze_exclude_keys(data, keys_to_exclude);
@@ -16,17 +16,26 @@ class <%= @migration_class_name %> < ActiveRecord::Migration | |||
end | |||
|
|||
execute <<-SQL | |||
CREATE OR REPLACE FUNCTION logidze_version(v bigint, data jsonb) RETURNS jsonb AS $body$ | |||
CREATE OR REPLACE FUNCTION logidze_version(v bigint, data jsonb, blacklist text DEFAULT '', whitelist text DEFAULT '') RETURNS jsonb AS $body$ |
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.
Maybe we can use here blacklist text[]
to avoid string_to_array
for every operation?
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.
Yes, i used blacklist text[] , but got problems with how to transform ruby string to pl pgSQL array and decided to use strings
BEGIN | ||
IF blacklist <> 'null' THEN | ||
filtered_array := logidze_exclude_keys(data, array['log_data']::text[] || string_to_array(blacklist, ',')); |
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.
Why not {"log_data"}
?
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.
When i tried this notation I was getting "PG::SyntaxError: ERROR: syntax error at or near "{"".
But today i found what it should be (data, '{log_data}')
.
|
||
let(:params) { { title: 'Triggers', rating: 10, active: false } } | ||
|
||
describe "backfill" do |
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.
Please, do not duplicate existing tests. Only test the feature you're working on.
If you want to check that the new options don't break existing functionality, just add them to the existing migrations.
good job! 👍 |
@palkan Thank you for review. |
@Neyaz Hi! How is it going?) |
Closed by #16 |
Hello,
it's my solution task on cultofmartians.