Skip to content

Commit 33cb906

Browse files
committed
Slight changes to regexp().
Use inline function form and add type annotations. Also add a link to the README.
1 parent bfb8939 commit 33cb906

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ subtract (generic function with 1 method)
207207

208208
The function that is defined can then be passed to `registerfunc`. `registerfunc` takes three arguments; the database to which the function should be registered, the number of arguments that the function takes and the function itself. The function is registered to the database connection rather than the database itself so must be registered each time the database opens. Your function can not take more than 127 arguments unless it takes a variable number of arguments, if it does take a variable number of arguments then you must pass -1 as the second argument to `registerfunc`.
209209

210-
The `@scalarfunc` macro uses the `sqlreturn` function to return your function's return value to SQLite. By default, `sqlreturn` maps the returned value to a [native SQLite type]() or, failing that, serializes the julia value and stores it as a `BLOB`. To change this behaviour simply define a new method for `sqlreturn` which then calls a previously defined method for `sqlreturn`. Methods which map to native SQLite types are
210+
The `@scalarfunc` macro uses the `sqlreturn` function to return your function's return value to SQLite. By default, `sqlreturn` maps the returned value to a [native SQLite type](http://sqlite.org/c3ref/result_blob.html) or, failing that, serializes the julia value and stores it as a `BLOB`. To change this behaviour simply define a new method for `sqlreturn` which then calls a previously defined method for `sqlreturn`. Methods which map to native SQLite types are
211211

212212
```julia
213213
sqlreturn(context, ::NullType)

src/UDF.jl

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,7 @@ macro scalarfunc(args...)
114114
end
115115

116116

117-
# If ismatch() had a method ismatch(::String, ::String) this could simply be
118-
# @scalarfunc regexp ismatch
119-
@scalarfunc function regexp(r, s)
120-
r = Regex(r)
121-
ismatch(r, s)
122-
end
123-
# macro for preserving the backslashes in a string
117+
# annotate types because the MethodError makes more sense that way
118+
@scalarfunc regexp(r::String, s::String) = ismatch(Regex(r), s)
119+
# macro for preserving the special characters in a string
124120
macro sr_str(s) s end

0 commit comments

Comments
 (0)