Skip to content

Commit 5be4600

Browse files
committed
Rename to SQLStrings as requested for General registry
This capitalization is a little more consistent with the naming in the rest of the Julia SQL ecosystem.
1 parent 9a04ac4 commit 5be4600

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name = "SqlStrings"
1+
name = "SQLStrings"
22
uuid = "af517c2e-c243-48fa-aab8-efac3db270f5"
33
authors = ["Chris Foster <chris42f@gmail.com> and contributors"]
44
version = "0.1.0"

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# SqlStrings
1+
# SQLStrings
22

3-
SqlStrings.jl provides the `@sql_cmd` macro to allow SQL query strings to be
3+
SQLStrings.jl provides the `@sql_cmd` macro to allow SQL query strings to be
44
constructed by normal-looking string interpolation but without risking SQL
55
formatting errors or SQL injection attacks on your application. For example,
66
the code
@@ -14,7 +14,7 @@ is vulerable to the canonical SQL injection attack:
1414

1515
[![Little Bobby Tables](https://imgs.xkcd.com/comics/exploits_of_a_mom.png)](https://xkcd.com/327)
1616

17-
Here's how to make this safe using SqlStrings.jl:
17+
Here's how to make this safe using SQLStrings.jl:
1818

1919
```julia
2020
query = sql`INSERT INTO Students VALUES ($name, $age, $class)`
@@ -34,11 +34,11 @@ code. In the examples below we'll use with LibPQ.jl and a `runquery()` function
3434
(hopefully integration will be automatic in future).
3535

3636
```julia
37-
using SqlStrings
37+
using SQLStrings
3838
import LibPQ
3939

40-
runquery(conn, sql::SqlStrings.Sql)
41-
query, args = SqlStrings.prepare(sql)
40+
runquery(conn, sql::SQLStrings.Sql)
41+
query, args = SQLStrings.prepare(sql)
4242
LibPQ.execute(conn, query, args)
4343
end
4444
```
@@ -138,7 +138,7 @@ larger SQL query which does more of the logic on the SQL side.
138138

139139
# Design
140140

141-
`SqlStrings` is a minimal approach to integrating SQL with Julia code in a safe
141+
`SQLStrings` is a minimal approach to integrating SQL with Julia code in a safe
142142
way — it understands only the basic rules of SQL quoting and Julia string
143143
interpolation, but does no other parsing of the source text. This allows tight
144144
integration with your database of choice by being unopinionated about its

src/SqlStrings.jl src/SQLStrings.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module SqlStrings
1+
module SQLStrings
22

33
export @sql_cmd
44

@@ -145,7 +145,7 @@ Julia code.
145145
so using `'A \$literal string'` will include `\$literal` rather than the value
146146
of the variable `literal`. If converting code from using raw strings, you may
147147
have needed to quote interpolations. In that case you can check your conversion
148-
by setting `SqlStrings.allow_dollars_in_strings[] = false`.
148+
by setting `SQLStrings.allow_dollars_in_strings[] = false`.
149149
150150
If you need to include a literal `\$` in the SQL code outside a string, you can
151151
escape it with `\\\$`.

test/runtests.jl

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
using SqlStrings
1+
using SQLStrings
22
using Test
33
using UUIDs
44

5-
querystr(q) = SqlStrings.prepare(q)[1]
6-
queryargs(q) = SqlStrings.prepare(q)[2]
5+
querystr(q) = SQLStrings.prepare(q)[1]
6+
queryargs(q) = SQLStrings.prepare(q)[2]
77

8-
@testset "SqlStrings.jl" begin
8+
@testset "SQLStrings.jl" begin
99
x = 1
1010
y = 2
1111
q1 = sql`select a where b=$x and c=$(x+y)`
@@ -28,7 +28,7 @@ queryargs(q) = SqlStrings.prepare(q)[2]
2828
# On occasion, we need to interpolate in a literal string rather than use a
2929
# parameter. Test that interpolating Literal works for this case.
3030
column = "x"
31-
@test querystr(sql`select $(SqlStrings.Literal(column)) from a`) ==
31+
@test querystr(sql`select $(SQLStrings.Literal(column)) from a`) ==
3232
raw"select x from a"
3333

3434
# Test splatting syntax
@@ -38,8 +38,8 @@ queryargs(q) = SqlStrings.prepare(q)[2]
3838
@test queryargs(q4) == z
3939

4040
# Test that Literal turns values into strings
41-
@test SqlStrings.Literal(:col_name).fragment == "col_name"
42-
@test SqlStrings.Literal(1).fragment == "1"
41+
@test SQLStrings.Literal(:col_name).fragment == "col_name"
42+
@test SQLStrings.Literal(1).fragment == "1"
4343

4444
# Test dollars inside SQL strings - the $x here should be a literal.
4545
q5 = sql`select $y where x = '$x'`
@@ -49,8 +49,8 @@ queryargs(q) = SqlStrings.prepare(q)[2]
4949
q6 = sql`some literal \$a`
5050
@test querystr(q6) == raw"some literal $a"
5151

52-
SqlStrings.allow_dollars_in_strings[] = false
52+
SQLStrings.allow_dollars_in_strings[] = false
5353
@test_throws LoadError @macroexpand sql`select $y where x = '$x'`
54-
SqlStrings.allow_dollars_in_strings[] = true
54+
SQLStrings.allow_dollars_in_strings[] = true
5555
end
5656

0 commit comments

Comments
 (0)