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

Readonly Access still writing into database #9

Open
maloneyl opened this issue Mar 4, 2016 · 0 comments

Comments

Projects
None yet
1 participant
@maloneyl
Copy link

commented Mar 4, 2016

I followed the Readonly Access example in the readme and found that updates still managed to be written:

[9] pry(main)> customer.first_name = "Wheeeee"
=> "Wheeeee"
[10] pry(main)> customer.save

From: /Users/xxxxxxx/Development/xxxxxxxx/config/initializers/arproxy.rb @ line 7 Readonly#execute:

    2: def execute(sql, name=nil)
    3:   if sql =~ /\s*(SELECT|SET|SHOW|DESCRIBE)\b/
    4:     super sql, name
    5:   else
    6:     binding.pry
 => 7:     Rails.logger.warn "#{name} (BLOCKED) #{sql}"
    8:   end
    9: end

[3] pry(#<Readonly>)> sql
=> "BEGIN"
[4] pry(#<Readonly>)> c
 (BLOCKED) BEGIN
  SQL (1.3ms)  UPDATE "customers" SET "first_name" = $1, "updated_at" = $2 WHERE "customers"."id" = $3  [["first_name", "Wheeeee"], ["updated_at", "2016-03-04 15:57:59.788986"], ["id", "f86d3094-a36f-499b-92ee-a78a76168750"]]

From: /Users/xxxxxxx/Development/xxxxxxxx/config/initializers/arproxy.rb @ line 7 Readonly#execute:

    2: def execute(sql, name=nil)
    3:   if sql =~ /\s*(SELECT|SET|SHOW|DESCRIBE)\b/
    4:     super sql, name
    5:   else
    6:     binding.pry
 => 7:     Rails.logger.warn "#{name} (BLOCKED) #{sql}"
    8:   end
    9: end

[4] pry(#<Readonly>)> sql
=> "COMMIT"
[5] pry(#<Readonly>)> c
 (BLOCKED) COMMIT
=> true

Any pointers how I could make this truly read-only? I'm using the PostgreSQLAdapter instead of MySQL as you have in your example, if that makes any difference. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.