Class: Waldit::PostgreSQLAdapter
- Inherits:
-
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
- Object
- ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
- Waldit::PostgreSQLAdapter
- Defined in:
- lib/waldit/postgresql_adapter.rb
Constant Summary collapse
- READ_QUERY_REGEXP =
build_read_query_regexp(*%i[close create declare drop fetch move set show])
Instance Method Summary collapse
- #begin_db_transaction ⇒ Object
- #begin_isolated_db_transaction ⇒ Object
- #commit_db_transaction ⇒ Object
- #exec_cache(sql) ⇒ Object
- #exec_no_cache(sql) ⇒ Object
- #raw_execute(sql) ⇒ Object
Instance Method Details
#begin_db_transaction ⇒ Object
69 70 71 72 |
# File 'lib/waldit/postgresql_adapter.rb', line 69 def begin_db_transaction(...) @current_waldit_context = nil.hash super end |
#begin_isolated_db_transaction ⇒ Object
74 75 76 77 |
# File 'lib/waldit/postgresql_adapter.rb', line 74 def begin_isolated_db_transaction(...) @current_waldit_context = nil.hash super end |
#commit_db_transaction ⇒ Object
79 80 81 82 |
# File 'lib/waldit/postgresql_adapter.rb', line 79 def commit_db_transaction @current_waldit_context = nil.hash super end |
#exec_cache(sql) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/waldit/postgresql_adapter.rb', line 49 def exec_cache(sql, ...) return super if READ_QUERY_REGEXP.match? sql return super if @current_waldit_context == Waldit.context.hash if transaction_open? set_waldit_context! super elsif Waldit.context # We are trying to execute a query with waldit context while not in a transaction, so we start one transaction do set_waldit_context! super end else super end end |
#exec_no_cache(sql) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/waldit/postgresql_adapter.rb', line 29 def exec_no_cache(sql, ...) return super if READ_QUERY_REGEXP.match? sql return super if @current_waldit_context == Waldit.context.hash if transaction_open? set_waldit_context! super elsif Waldit.context # We are trying to execute a query with waldit context while not in a transaction, so we start one transaction do set_waldit_context! super end else super end end |
#raw_execute(sql) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/waldit/postgresql_adapter.rb', line 9 def raw_execute(sql, ...) return super if READ_QUERY_REGEXP.match? sql return super if @current_waldit_context == Waldit.context.hash if transaction_open? set_waldit_context! super elsif Waldit.context # We are trying to execute a query with waldit context while not in a transaction, so we start one transaction do set_waldit_context! super end else super end end |