-
-
Notifications
You must be signed in to change notification settings - Fork 133
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Code of Conduct
- I agree to follow this project's Code of Conduct
AI Policy
- I agree to follow this project's AI Policy, or I agree that AI was not used while creating this issue.
Versions
Hex: 2.3.2
Elixir: 1.19.4
OTP: 28.3
ash_postgres 2.6.32
Operating system
NixOS
Current Behavior
Locks like "FOR UPDATE SKIP LOCKED" should be supported. But if you run AshPostgres.DataLayer.can?(Resource, {:lock, "FOR UPDATE SKIP LOCKED"}) you will get false.
Reproduction
Basically add Ash.Query.lock("FOR UPDATE SKIP LOCKED") to a read action in any resource thas uses AshPostgres.
Based on the lock function:
ash_postgres/lib/data_layer.ex
Line 3600 in f15ddb2
| lock = "#{lock} SKIP LOCKED" |
These types of lock are supported, but they will fail because ash will first call
can? and that will return false.
The issue is in this code:
ash_postgres/lib/data_layer.ex
Line 689 in f15ddb2
| def can?(_, {:lock, string}) do |
def can?(_, {:lock, string}) do
string = String.trim_trailing(string, " NOWAIT")
String.upcase(string) in [
"FOR UPDATE",
"FOR NO KEY UPDATE",
"FOR SHARE",
"FOR KEY SHARE"
]
endAs you can see, This can logic is incorrect, it should probably be something like this:
def can?(_, {:lock, string}) do
string |> String.trim_trailing(" NOWAIT") |> String.upcase() |> can_lock?()
end
def can_lock?("FOR UPDATE" <> _), do: true
def can_lock?("FOR NO KEY UPDATE" <> _), do: true
def can_lock?("FOR SHARE" <> _), do: true
def can_lock?("FOR KEY SHARE" <> _), do: true
def can_lock?(_), do: falseExpected Behavior
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working