Skip to content

Commit

Permalink
Add test of NULL SQL value handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ndptech committed Oct 21, 2024
1 parent 6294960 commit ccc654a
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/tests/modules/sql/map.unlang
Original file line number Diff line number Diff line change
Expand Up @@ -295,4 +295,28 @@ if (!notfound) {
test_fail
}

# Clear the control list
&control -= &User-Name[*]
&control -= &Filter-Id[*]

# Check behaviour of NULL vs empty string returns.
# radacct is used here as the default schema allows NULL in many columns
%sql("DELETE FROM radacct WHERE acctuniqueid = 'nullmap'")
%sql("INSERT INTO radacct (acctuniqueid, acctsessionid, nasipaddress, username) VALUES ('nullmap', 'nullmap', '10.11.12.13', '')")
map sql "SELECT username, connectinfo_start, nasipaddress FROM radacct WHERE acctuniqueid = 'nullmap'" {
&control.User-Name := 'username'
&control.Filter-Id := 'connectinfo_start'
&control.NAS-IP-Address := 'nasipaddress'
}

if !(&control.User-Name == '') {
test_fail
}
if (&control.Filter-Id) {
test_fail
}
if !(&control.NAS-IP-Address == 10.11.12.13) {
test_fail
}

test_pass

0 comments on commit ccc654a

Please sign in to comment.