Skip to content

Commit 34e38e6

Browse files
committed
doc fixes
1 parent 6da7c16 commit 34e38e6

8 files changed

Lines changed: 28 additions & 58 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
[![Build Status](https://travis-ci.org/queryverse/QuerySQLite.jl.svg?branch=master)](https://travis-ci.org/queryverse/QuerySQLite.jl)
55
[![Build status](https://ci.appveyor.com/api/projects/status/vluand1dj4x7i3iy/branch/master?svg=true)](https://ci.appveyor.com/project/queryverse/querysqlite-jl/branch/master)
66
[![codecov.io](http://codecov.io/github/queryverse/QuerySQLite.jl/coverage.svg?branch=master)](http://codecov.io/github/queryverse/QuerySQLite.jl?branch=master)
7+
[![dev](https://img.shields.io/badge/docs-latest-blue.svg)](http://www.queryverse.org/QuerySQLite.jl/dev/)
78

89
This package provides a SQLite backend for [Query.jl](https://github.com/queryverse/Query.jl).

docs/src/index.md

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,31 @@
1+
# QuerySQLite
2+
13
```@index
24
Modules = [QuerySQLite]
35
```
46

57
## User documentation
68

7-
QuerySQLite is an experimental package sponsored by Google Summer of Code. It's
8-
finally ready for public use. Although QuerySQLite is only tested on SQLite,
9-
it's been purposefully designed to easily incorporate other database software.
9+
QuerySQLite is an experimental package sponsored by Google Summer of Code. It's finally ready for public use. Although QuerySQLite is only tested using SQLite, it's been purposefully designed to easily incorporate other database software.
1010

11-
Use [`Database`](@ref) to wrap an external database. Then, you can access its
12-
tables using `.`, and conduct most `Query` operations on them. In theory, most
13-
operations should "just work". There are a couple of exceptions.
11+
Use [`Database`](@ref) to wrap an external database. Then, you can access its tables using `.`, and conduct most `Query` operations on them. In theory, most operations should "just work". There are a couple of exceptions.
1412

15-
### Non-overloadable methods
13+
### Non-overloadable syntax and functions
1614

17-
Functions like `ifelse` and `typeof` can't be overloaded. Instead, QuerySQLite
18-
exports the [`if_else`](@ref) and [`type_of`](@ref) functions and overloads them
19-
instead.
15+
Patterns like `if` and functions like `ifelse` and `typeof` can't be overloaded. Instead, QuerySQLite exports the [`if_else`](@ref) and [`type_of`](@ref) functions and overloads them instead.
2016

2117
### No SQL arguments
2218

23-
If you would like to translate code to SQL, but you do not pass any SQL
24-
arguments, you will need use [`BySQL`](@ref) to pass a dummy SQL object instead.
25-
See the `BySQL` docstring for more information.
19+
If you would like to translate code to SQL, but you do not pass any SQL arguments, you will need to use [`BySQL`](@ref) to pass a dummy SQL object instead. See the `BySQL` docstring for more information.
2620

2721
## Developer documentation
2822

29-
QuerySQLite hijacks Julia's multiple dispatch to translate external database
30-
commands to SQL instead of evaluating them. To do this, it construct a
31-
"model_row" that represents the structure of a row of data. If you would like to
32-
support for a new function, there are only a few steps:
33-
34-
- Use the `@code_instead` macro to specify the argument types for diversion
35-
into SQL translation.
36-
- If your function will modify the row structure of the
37-
table, define a `model_row_call` method.
38-
- Use the `@translate_default` macro to name the matching SQL function. If more
39-
involved processing is required, define a `translate_call` method instead.
40-
- If you would like to show your SQL expression in a non-standard way, edit the
41-
`show` method for `SQLExpression`s.
23+
QuerySQLite hijacks Julia's multiple dispatch to translate external database commands to SQL instead of evaluating them. To do this, it constructs a "model_row" that represents the structure of a row of data. If you would like to add support for a new function, there are only a few steps:
24+
25+
- Use the `@code_instead` macro to specify the argument types for diversion into SQL translation.
26+
- If your function will modify the row structure of the table, define a `model_row_call` method.
27+
- Use the `@translate_default` macro to name the matching SQL function. If more involved processing is required, define a `translate_call` method instead.
28+
- If you would like to show your SQL expression in a non-standard way, edit the `show` method for `SQLExpression`s.
4229

4330
```@autodocs
4431
Modules = [QuerySQLite]

src/QuerySQLite.jl

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,4 @@ include("model_row.jl")
3232
include("translate.jl")
3333
include("show.jl")
3434

35-
# To add support for a new function
36-
# 1) Use `@code_instead` to specify the argument types
37-
# 2) If the function modifies the model row, define model_row_call(::typeof(function), ...)
38-
# 3a) If the function maps directly onto an SQL function, use @translate_default function SQL_function_symbol
39-
# 3b) Otherwise, define translate_call(::typeof(function), ...)
40-
# 4) If the SQL function uses special syntax, special case the SQLExpression show method
41-
42-
# There are two situtations in which Julia code cannot be translated into SQL
43-
# 1) Patterns based on non-functions or non-overloadable functions, e.g. if, &&. Use if_else and & instead
44-
# 2) Separate operations in SQL that are combined in Julia by dispatch, e.g. * for string concatention. Use `string` instead
45-
4635
end # module

src/code_instead.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# All code is attached to its underlying database source
22
struct SourceCode{Source}
33
source::Source
4-
code::Union{Expr, Nothing}
4+
code::Expr
55
end
66

77
"""
@@ -71,7 +71,6 @@ function combine_sources(a_function, source_codes...; key_source_codes...)
7171
end
7272
end
7373

74-
# `@code_instead` hijacks call to create Julia expressions instead of evaluating functions
7574
function numbered_argument(number)
7675
Symbol(string("argument", number))
7776
end
@@ -89,6 +88,7 @@ function maybe_splat(argument, a_type)
8988
end
9089
end
9190

91+
# `@code_instead` hijacks call to create Julia expressions instead of evaluating functions
9292
function code_instead(location, a_function, types...)
9393
arguments = ntuple(numbered_argument, length(types))
9494
keywords = Expr(:parameters, Expr(:..., :keywords))

src/database.jl

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ export get_column_names
4141
4242
A wrapper for an external database. `source` need only support
4343
[`get_table_names`](@ref) and [`get_column_names`](@ref).
44+
"""
45+
struct Database{Source}
46+
source::Source
47+
end
48+
49+
"""
50+
Database(filename::AbstractString)
51+
52+
Guess the database software from the filename.
53+
4454
4555
```jldoctest
4656
julia> using QuerySQLite
@@ -64,15 +74,6 @@ TrackId │ Name │ AlbumId │ MediaTypeI
6474
... with more rows, and 5 more columns: GenreId, Composer, Milliseconds, Bytes, UnitPrice
6575
```
6676
"""
67-
struct Database{Source}
68-
source::Source
69-
end
70-
71-
"""
72-
Database(filename::AbstractString)
73-
74-
Guess the database software from the filename.
75-
"""
7677
function Database(filename::AbstractString)
7778
if endswith(filename, ".sqlite")
7879
Database(SQLite.DB(filename))

src/functions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export type_of
7070
"""
7171
hex(it)
7272
73-
Uppercase heximal representation
73+
Uppercase hexadecimal representation
7474
7575
```jldoctest
7676
julia> using QuerySQLite

src/show.jl

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,6 @@ function tight_infix(io, call, argument1, argument2)
2525
print(io, argument2)
2626
end
2727

28-
function parenthesize_infix(io, call, argument1, argument2)
29-
print(io, argument1)
30-
print(io, ' ')
31-
print(io, call)
32-
print(io, ' ')
33-
print(io, argument2)
34-
end
35-
3628
function infix(io, call, argument1, argument2, arguments...)
3729
print(io, argument1)
3830
print(io, ' ')
@@ -111,7 +103,7 @@ function show(io::IO, sql_expression::SQLExpression)
111103
elseif call === :AND
112104
infix(io, call, arguments...)
113105
elseif call === :AS
114-
parenthesize_infix(io, call, arguments...)
106+
infix(io, call, arguments...)
115107
elseif call === :CASE
116108
case(io, call, arguments...)
117109
elseif call === :DESC

test/test.sqlite

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)