Compare 4645117 ... +2 ... 8bcd162

Flags

Flags have been temporarily removed from this view while the flagging feature is refactored for better performance and user experience.

You can still use flags when viewing individual files. Flag-level thresholds will also remain on pull and merge requests in your repository provider.

More information can be found in our documentation.

Showing 3 of 5 files from the diff.

@@ -10,30 +10,30 @@
Loading
10 10
    SQLExpression(:AS, SQLExpression(:FROM, sql_expression), :__TABLE__)
11 11
end
12 12
13 -
function translate(something::Union{Char,AbstractString}; _primary = true)
13 +
function translate(something::Union{Char,AbstractString}; _primary=true)
14 14
    repr(something)
15 15
end
16 16
17 -
function translate(something; _primary = true)
17 +
function translate(something; _primary=true)
18 18
    something
19 19
end
20 -
function translate(source_row::SourceRow; _primary = true)
20 +
function translate(source_row::SourceRow; _primary=true)
21 21
    source_row.table_name
22 22
end
23 -
function translate(call::Expr; _primary = true)
23 +
function translate(call::Expr; _primary=true)
24 24
    arguments, keywords = split_call(call)
25 -
    translate_call(arguments...; _primary = _primary, keywords...)
25 +
    translate_call(arguments...; _primary=_primary, keywords...)
26 26
end
27 27
28 28
# A 1-1 mapping between Julia functions and SQL functions
29 29
function translate_default(location, function_type, SQL_call)
30 30
    result = :(
31 -
        function translate_call($function_type, arguments...; _primary = true)
32 -
        $SQLExpression($SQL_call, $map(
33 -
                argument->$translate(argument; _primary = _primary),
31 +
        function translate_call($function_type, arguments...; _primary=true)
32 +
            $SQLExpression($SQL_call, $map(
33 +
                argument -> $translate(argument; _primary=_primary),
34 34
                arguments
35 35
            )...)
36 -
    end
36 +
        end
37 37
    )
38 38
    result.args[2].args[1] = location
39 39
    result
@@ -65,9 +65,9 @@
Loading
65 65
66 66
@translate_default ::typeof(abs) :ABS
67 67
68 -
function as(pair; _primary = true)
68 +
function as(pair; _primary=true)
69 69
    SQLExpression(:AS,
70 -
        translate(pair.second.code; _primary = _primary),
70 +
        translate(pair.second.code; _primary=_primary),
71 71
        pair.first
72 72
    )
73 73
end
@@ -76,56 +76,56 @@
Loading
76 76
77 77
@translate_default ::typeof(char) :CHAR
78 78
79 -
function translate_call(::typeof(convert), ::Type{Int}, it; _primary = true)
79 +
function translate_call(::typeof(convert), ::Type{Int}, it; _primary=true)
80 80
    SQLExpression(:UNICODE, translate(it))
81 81
end
82 82
83 83
@translate_default ::typeof(hex) :HEX
84 84
85 85
@translate_default ::typeof(QueryOperators.drop) :OFFSET
86 86
87 -
function translate_call(::typeof(QueryOperators.filter), iterator, call, call_expression; _primary = true)
87 +
function translate_call(::typeof(QueryOperators.filter), iterator, call, call_expression; _primary=true)
88 88
    SQLExpression(:WHERE,
89 -
        translate(iterator; _primary = _primary),
90 -
        translate(call(model_row(iterator)).code; _primary = _primary)
89 +
        translate(iterator; _primary=_primary),
90 +
        translate(call(model_row(iterator)).code; _primary=_primary)
91 91
    )
92 92
end
93 93
94 -
function translate_call(::typeof(format), time_type, format_string; _primary = true)
94 +
function translate_call(::typeof(format), time_type, format_string; _primary=true)
95 95
    SQLExpression(
96 96
        :STRFTIME,
97 -
        translate(format_string; _primary = _primary),
98 -
        translate(time_type; _primary = _primary)
97 +
        translate(format_string; _primary=_primary),
98 +
        translate(time_type; _primary=_primary)
99 99
    )
100 100
end
101 101
102 -
function translate_call(::typeof(getproperty), source_tables::Database, table_name; _primary = true)
103 -
    translated = translate(table_name; _primary = _primary)
102 +
function translate_call(::typeof(getproperty), source_tables::Database, table_name; _primary=true)
103 +
    translated = translate(table_name; _primary=_primary)
104 104
    if _primary
105 105
        SQLExpression(:FROM, translated)
106 106
    else
107 107
        translated
108 108
    end
109 109
end
110 -
function translate_call(::typeof(getproperty), source_row::SourceRow, column_name; _primary = true)
111 -
    translated = translate(column_name; _primary = _primary)
110 +
function translate_call(::typeof(getproperty), source_row::SourceRow, column_name; _primary=true)
111 +
    translated = translate(column_name; _primary=_primary)
112 112
    if _primary
113 113
        translated
114 114
    else
115 115
        SQLExpression(:., source_row.table_name, translated)
116 116
    end
117 117
end
118 118
119 -
function translate_call(::typeof(QueryOperators.groupby), ungrouped, group_function, group_function_expression, map_selector, map_function_expression; _primary = true)
119 +
function translate_call(::typeof(QueryOperators.groupby), ungrouped, group_function, group_function_expression, map_selector, map_function_expression; _primary=true)
120 120
    model = model_row(ungrouped)
121 121
    SQLExpression(Symbol("GROUP BY"),
122 122
        nest(translate_call(
123 123
            QueryOperators.map,
124 124
            ungrouped,
125 125
            map_selector, map_function_expression,
126 -
            _primary = _primary
126 +
            _primary=_primary
127 127
        )),
128 -
        translate(group_function(model).code; _primary = _primary)
128 +
        translate(group_function(model).code; _primary=_primary)
129 129
    )
130 130
end
131 131
@@ -143,25 +143,25 @@
Loading
143 143
144 144
@translate_default ::typeof(join) :GROUP_CONCAT
145 145
146 -
function translate_call(::typeof(QueryOperators.join), source1, source2, key1, key1_expression, key2, key2_expression, combine, combine_expression; _primary = true)
146 +
function translate_call(::typeof(QueryOperators.join), source1, source2, key1, key1_expression, key2, key2_expression, combine, combine_expression; _primary=true)
147 147
    model_row_1 = model_row(source1)
148 148
    model_row_2 = model_row(source2)
149 149
    SQLExpression(:SELECT,
150 150
        SQLExpression(:ON,
151 151
            SQLExpression(Symbol("INNER JOIN"),
152 152
                translate(source1),
153 153
                # mark as not _primary to suppress FROM
154 -
                translate(source2; _primary = false)
154 +
                translate(source2; _primary=false)
155 155
            ),
156 156
            # mark both as not _primary to always be explicit about table
157 157
            SQLExpression(:(=),
158 -
                translate(key1(model_row_1).code; _primary = false),
159 -
                translate(key2(model_row_2).code; _primary = false)
158 +
                translate(key1(model_row_1).code; _primary=false),
159 +
                translate(key2(model_row_2).code; _primary=false)
160 160
            )
161 161
        ),
162 162
        # mark both as not _primary to always be explicit about table
163 163
        Generator(
164 -
            pair->as(pair; _primary = false),
164 +
            pair -> as(pair; _primary=false),
165 165
            pairs(combine(model_row_1, model_row_2))
166 166
        )...
167 167
    )
@@ -171,15 +171,15 @@
Loading
171 171
172 172
@translate_default ::typeof(lowercase) :LOWER
173 173
174 -
function translate_call(::typeof(QueryOperators.map), select_table, call, call_expression; _primary = true)
175 -
    inner = translate(select_table; _primary = _primary)
174 +
function translate_call(::typeof(QueryOperators.map), select_table, call, call_expression; _primary=true)
175 +
    inner = translate(select_table; _primary=_primary)
176 176
    if inner.call == :SELECT
177 177
        inner = nest(inner)
178 178
    end
179 179
    SQLExpression(
180 180
        :SELECT, inner,
181 181
        Generator(
182 -
            pair->as(pair; _primary = _primary),
182 +
            pair -> as(pair; _primary=_primary),
183 183
            pairs(call(model_row(select_table)))
184 184
        )...
185 185
    )
@@ -193,49 +193,49 @@
Loading
193 193
@translate_default ::typeof(min) :min
194 194
@translate_default ::typeof(minimum) :min
195 195
196 -
translate_call(::typeof(occursin), needle, haystack; _primary = true) =
196 +
translate_call(::typeof(occursin), needle, haystack; _primary=true) =
197 197
    SQLExpression(
198 198
        :LIKE,
199 -
        translate(haystack; _primary = _primary),
200 -
        translate(needle; _primary = _primary)
199 +
        translate(haystack; _primary=_primary),
200 +
        translate(needle; _primary=_primary)
201 201
    )
202 202
203 -
function translate_call(::typeof(QueryOperators.orderby), unordered, key_function, key_function_expression; _primary = true)
203 +
function translate_call(::typeof(QueryOperators.orderby), unordered, key_function, key_function_expression; _primary=true)
204 204
    SQLExpression(Symbol("ORDER BY"),
205 -
        translate(unordered; _primary = _primary),
206 -
        translate(key_function(model_row(unordered)).code; _primary = _primary)
205 +
        translate(unordered; _primary=_primary),
206 +
        translate(key_function(model_row(unordered)).code; _primary=_primary)
207 207
    )
208 208
end
209 209
210 -
function translate_call(::typeof(QueryOperators.orderby_descending), unordered, key_function, key_function_expression; _primary = true)
210 +
function translate_call(::typeof(QueryOperators.orderby_descending), unordered, key_function, key_function_expression; _primary=true)
211 211
    SQLExpression(Symbol("ORDER BY"),
212 -
        translate(unordered; _primary = _primary),
212 +
        translate(unordered; _primary=_primary),
213 213
        SQLExpression(:DESC,
214 -
            translate(key_function(model_row(unordered)).code; _primary = _primary)
214 +
            translate(key_function(model_row(unordered)).code; _primary=_primary)
215 215
        )
216 216
    )
217 217
end
218 218
219 219
@translate_default ::typeof(repr) :QUOTE
220 220
221 -
function translate_call(::typeof(rand), ::Type{Int}; _primary = true)
221 +
function translate_call(::typeof(rand), ::Type{Int}; _primary=true)
222 222
    SQLExpression(:RANDOM)
223 223
end
224 224
225 225
@translate_default ::typeof(randstring) :RANDOMBLOB
226 226
227 -
function translate_call(::typeof(replace), it, pair; _primary = true)
227 +
function translate_call(::typeof(replace), it, pair; _primary=true)
228 228
    SQLExpression(:REPLACE,
229 -
        translate(it; _primary = _primary),
230 -
        translate(pair.first; _primary = _primary),
231 -
        translate(pair.second; _primary = _primary)
229 +
        translate(it; _primary=_primary),
230 +
        translate(pair.first; _primary=_primary),
231 +
        translate(pair.second; _primary=_primary)
232 232
    )
233 233
end
234 234
235 -
function translate_call(::typeof(round), it; _primary = true, digits = 0)
235 +
function translate_call(::typeof(round), it; _primary=true, digits=0)
236 236
    SQLExpression(:ROUND,
237 -
        translate(it; _primary = _primary),
238 -
        translate(digits; _primary = _primary)
237 +
        translate(it; _primary=_primary),
238 +
        translate(digits; _primary=_primary)
239 239
    )
240 240
end
241 241
@@ -249,26 +249,26 @@
Loading
249 249
250 250
@translate_default ::typeof(QueryOperators.take) :LIMIT
251 251
252 -
function translate_call(::typeof(QueryOperators.thenby), unordered, key_function, key_function_expression; _primary = true)
253 -
    original = translate(unordered; _primary = _primary)
252 +
function translate_call(::typeof(QueryOperators.thenby), unordered, key_function, key_function_expression; _primary=true)
253 +
    original = translate(unordered; _primary=_primary)
254 254
    SQLExpression(original.call, original.arguments...,
255 -
        translate(key_function(model_row(unordered)).code; _primary = _primary)
255 +
        translate(key_function(model_row(unordered)).code; _primary=_primary)
256 256
    )
257 257
end
258 258
259 -
function translate_call(::typeof(QueryOperators.thenby_descending), unordered, key_function, key_function_expression; _primary = true)
260 -
    original = translate(unordered; _primary = _primary)
259 +
function translate_call(::typeof(QueryOperators.thenby_descending), unordered, key_function, key_function_expression; _primary=true)
260 +
    original = translate(unordered; _primary=_primary)
261 261
    SQLExpression(original.call, original.arguments...,
262 262
        SQLExpression(:DESC,
263 -
            translate(key_function(model_row(unordered)).code; _primary = _primary)
263 +
            translate(key_function(model_row(unordered)).code; _primary=_primary)
264 264
        )
265 265
    )
266 266
end
267 267
268 268
@translate_default ::typeof(type_of) :TYPEOF
269 269
270 -
function translate_call(::typeof(QueryOperators.unique), repeated, key_function, key_function_expression; _primary = true)
271 -
    result = translate(repeated; _primary = _primary)
270 +
function translate_call(::typeof(QueryOperators.unique), repeated, key_function, key_function_expression; _primary=true)
271 +
    result = translate(repeated; _primary=_primary)
272 272
    SQLExpression(Symbol(string(result.call, " DISTINCT")), result.arguments...)
273 273
end
274 274

@@ -80,7 +80,7 @@
Loading
80 80
```
81 81
"""
82 82
function hex(it::Number)
83 -
    uppercase(string(it, base = 16))
83 +
    uppercase(string(it, base=16))
84 84
end
85 85
function hex(it::AbstractString)
86 86
    join(hex(byte) for byte in codeunits(it))

@@ -94,7 +94,7 @@
Loading
94 94
    value_2
95 95
end
96 96
97 -
function name_and_type(handle, column_number, nullable = true, strict_types = true)
97 +
function name_and_type(handle, column_number, nullable=true, strict_types=true)
98 98
    Symbol(unsafe_string(sqlite3_column_name(handle, column_number))),
99 99
    if strict_types
100 100
        julia_type = juliatype(handle, column_number)
@@ -118,8 +118,8 @@
Loading
118 118
    handle = statement.handle
119 119
    schema = ntuple(
120 120
        let handle = handle
121 -
        column_number->name_and_type(handle, column_number)
122 -
    end,
121 +
            column_number -> name_and_type(handle, column_number)
122 +
        end,
123 123
        sqlite3_column_count(handle)
124 124
    )
125 125
    SQLiteCursor{NamedTuple{Tuple(map(first, schema)),Tuple{map(second, schema)...}}}(statement, Ref(status), Ref(0))

Learn more Showing 1 files with coverage changes found.

Changes in src/code_instead.jl
-1
+1
Loading file...
Files Coverage
src 0.26% 89.38%
Project Totals (9 files) 89.38%
Loading