Skip to content

Readonly Access still writing into database #9

@maloneyl

Description

@maloneyl

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions