Skip to content
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

Quote view names #188

Merged
merged 1 commit into from Apr 13, 2017
Merged

Quote view names #188

merged 1 commit into from Apr 13, 2017

Conversation

calebhearth
Copy link
Contributor

No description provided.


Search.connection.drop_view :'scenic."search in a haystack"'

silence_stream(STDOUT) { eval(output) }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of eval is a serious security risk.


Search.connection.drop_view :'scenic."search in a haystack"'

silence_stream(STDOUT) { eval(output) }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of eval is a serious security risk.

it "dumps a create_view for a view in the database" do
view_definition = "SELECT 'needle'::text AS haystack"
Search.connection.execute(
"CREATE SCHEMA scenic; SET search_path TO scenic, public")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.

it "dumps a create_view for a view in the database" do
view_definition = "SELECT 'needle'::text AS haystack"
Search.connection.execute(
"CREATE SCHEMA scenic; SET search_path TO scenic, public")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.


Search.connection.drop_view :'"search in a haystack"'

silence_stream(STDOUT) { eval(output) }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of eval is a serious security risk.


Search.connection.drop_view :'"search in a haystack"'

silence_stream(STDOUT) { eval(output) }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of eval is a serious security risk.

context "with views using unexpected characters in name" do
it "dumps a create_view for a view in the database" do
view_definition = "SELECT 'needle'::text AS haystack"
Search.connection.create_view '"search in a haystack"', sql_definition: view_definition

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [93/80]

context "with views using unexpected characters in name" do
it "dumps a create_view for a view in the database" do
view_definition = "SELECT 'needle'::text AS haystack"
Search.connection.create_view '"search in a haystack"', sql_definition: view_definition

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [93/80]

@@ -43,9 +43,9 @@ def to_scenic_view(result)
namespace, viewname = result.values_at "namespace", "viewname"

if namespace != "public"
namespaced_viewname = "#{namespace}.#{viewname}"
namespaced_viewname = "#{pg_identifier(namespace)}.#{pg_identifier(viewname)}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [90/80]

@@ -43,9 +43,9 @@ def to_scenic_view(result)
namespace, viewname = result.values_at "namespace", "viewname"

if namespace != "public"
namespaced_viewname = "#{namespace}.#{viewname}"
namespaced_viewname = "#{pg_identifier(namespace)}.#{pg_identifier(viewname)}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [90/80]

@calebhearth
Copy link
Contributor Author

Closes #172

@@ -54,6 +54,11 @@ def to_scenic_view(result)
materialized: result["kind"] == "m",
)
end

def pg_identifier(name)
return name if name =~ /^[a-zA-Z_][a-zA-Z0-9_]*$/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not safely quote the identifier in any case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this line caused double quoting in in-memory representations of the names (failing tests) and in the SQL dump (failing more tests, and breaking things). I wasn't able to fix that in ~an hour, so I reverted my attempts.

@calebhearth
Copy link
Contributor Author

calebhearth commented Feb 10, 2017 via email

@calebhearth calebhearth force-pushed the quote-view-names branch 2 times, most recently from 29bfad8 to a56338c Compare April 13, 2017 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants