mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
fix(table): restore expected behavior in table_matches (#49)
- The refactor in [Commit4c460e0](4c460e0bd9) introduced stricter type checks (using table.type and array length comparison), which caused empty tables and tables with nil values to be considered unequal. - This commit removes the strict shape checks and restores the original deep equality semantics, ensuring {} == {x=nil}. Signed-off-by: RuksH4n <77233680+rukshanchamindu@users.noreply.github.com>
This commit is contained in:
@@ -47,9 +47,10 @@ end
|
||||
---@return boolean
|
||||
---Compares if two values are equal, iterating over tables and matching both keys and values.
|
||||
local function table_matches(t1, t2)
|
||||
local tabletype1 = table.type(t1)
|
||||
local type1, type2 = type(t1), type(t2)
|
||||
|
||||
if not tabletype1 then return t1 == t2 end
|
||||
if type1 ~= type2 then return false end
|
||||
if type1 ~= 'table' and type2 ~= 'table' then return t1 == t2 end
|
||||
|
||||
if tabletype1 ~= table.type(t2) or (tabletype1 == 'array' and #t1 ~= #t2) then
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user