@@ -10,6 +10,13 @@ defmodule Ecto.Adapters.MyXQL do
10
10
below. All options can be given via the repository
11
11
configuration:
12
12
13
+ config :your_app, YourApp.Repo,
14
+ ...
15
+
16
+ The `:prepare` option may be specified per operation:
17
+
18
+ YourApp.Repo.all(Queryable, prepare: :unnamed)
19
+
13
20
### Connection options
14
21
15
22
* `:protocol` - Set to `:socket` for using UNIX domain socket, or `:tcp` for TCP
@@ -147,6 +154,8 @@ defmodule Ecto.Adapters.MyXQL do
147
154
@ behaviour Ecto.Adapter.Storage
148
155
@ behaviour Ecto.Adapter.Structure
149
156
157
+ @ default_prepare_opt :named
158
+
150
159
## Custom MySQL types
151
160
152
161
@ impl true
@@ -171,6 +180,23 @@ defmodule Ecto.Adapters.MyXQL do
171
180
defp json_decode ( x ) when is_binary ( x ) , do: { :ok , MyXQL . json_library ( ) . decode! ( x ) }
172
181
defp json_decode ( x ) , do: { :ok , x }
173
182
183
+ ## Query API
184
+
185
+ @ impl Ecto.Adapter.Queryable
186
+ def execute ( adapter_meta , query_meta , query , params , opts ) do
187
+ prepare = Keyword . get ( opts , :prepare , @ default_prepare_opt )
188
+
189
+ unless valid_prepare? ( prepare ) do
190
+ raise ArgumentError ,
191
+ "expected option `:prepare` to be either `:named` or `:unnamed`, got: #{ inspect ( prepare ) } "
192
+ end
193
+
194
+ Ecto.Adapters.SQL . execute ( prepare , adapter_meta , query_meta , query , params , opts )
195
+ end
196
+
197
+ defp valid_prepare? ( prepare ) when prepare in [ :named , :unnamed ] , do: true
198
+ defp valid_prepare? ( _ ) , do: false
199
+
174
200
## Storage API
175
201
176
202
@ impl true
0 commit comments