Skip to content

Commit 2f87a00

Browse files
committed
add isempty(string)
1 parent 680143f commit 2f87a00

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

src/func_to_funsql.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func_to_funsql(f::Base.Fix2{typeof(replace),<:Pair{<:AbstractString,<:AbstractSt
4747
func_to_funsql(f::Base.Fix2{typeof(replace),<:Pair{<:Regex,<:AbstractString}}, arg) = Fun.regexp_replace(arg, f.x[1].pattern, f.x[2])
4848

4949

50+
func_to_funsql(::typeof(isempty), arg) = func_to_funsql(==(""), arg) # XXX: only handles strings, anything else can be isempty?
5051
func_to_funsql(f::typeof(lowercase), arg) = Fun.lower(arg)
5152
func_to_funsql(f::typeof(uppercase), arg) = Fun.upper(arg)
5253
func_to_funsql(f::typeof(strip), arg) = Fun.trim(arg)

test/runtests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ using TestItemRunner
2424

2525
# using Logging; ConsoleLogger(stdout, Logging.Debug) |> global_logger
2626

27-
data = [(;i, j=i/10, s=string('a'+i-1)^i, d=Date(2000+i, i, 2i), dt=DateTime(2000+i, i, 2i, i, 3i, 4i)) for i in 1:10]
27+
data = [(;i, j=i/10, s=string('a'+i-1)^(i-1), d=Date(2000+i, i, 2i), dt=DateTime(2000+i, i, 2i, i, 3i, 4i)) for i in 1:10]
2828

2929
@testset for db in [
3030
SQLite.DB(),
@@ -75,7 +75,7 @@ using TestItemRunner
7575
(@f map(@o (a=ifelse(_.i > 6, 1, 0),)) unique()),
7676
# (@f unique(@o _.i > 6)),
7777
(@f map(@o (a=string(_.i, "%"), b=string("x: ", _.j) * " and", c=string("y: ", _.i*10, " kg")))),
78-
(@f map(@o (a=uppercase(_.s), b=lowercase(_.s * "XX")))),
78+
(@f map(@o (a=uppercase(_.s), b=lowercase(_.s * "XX"), c=isempty(_.s)))),
7979
(@f map(@o (a=startswith(_.s, "cc"), b=endswith(_.s, "dd"), d=occursin("eee", _.s), e=startswith(_.s, "a%")))),
8080
([DuckDB.DB], @f map(@o (a=occursin("EeE", _.s), b=replace(_.s, r"e+" => "xxx"), c=replace(_.s, "e+" => "xxx"), d=replace(_.s, "bb" => "xxx")))),
8181
(@f map(@o (a=format(Format("x %d"), _.i),))),

0 commit comments

Comments
 (0)