Comments (7)
Perhaps the best option is to introduce a separate function, such as query_multi
or query_many
or similar. So users can explicitly opt-in into it.
from tds.
Released in v2.1.1.
Thank you!
from tds.
Last year I refactored decoder part, it reads and keeps all results until it must hadoff result to user code. Reason is that ecto expects only single result, so Tds.Protocol
pulls out last result here.
Since ecto adapter does not use Tds.query/3
nor Tds.query/4
it is possible to pass additional flag in options that should tell internally Tds.Protocol module to rather return all results. For instance, here it could be something like:
def query(pid, statement, params, opts \\ []) do
query = %Query{statement: statement}
opts =
opts
|> Keyword.put_new(:parameters, params)
|> Keyword.put(:resultset, true) # <----- THE FLAG!
case DBConnection.prepare_execute(pid, query, params, opts) do
{:ok, _query, result} -> {:ok, result}
{:error, err} -> {:error, err}
end
end
Then it could pack among all results additional info, like messages server returned (info, error ...), num_results, and result set count.
It is worth mentioning that results are in reverse order so they need to be Enum.reverse
d before they are handed to user code.
from tds.
One more note, since unit tests also expect single Tds.Result, all must be refactored to pass with this change
from tds.
@josevalim, @ekstrom , I think this is going to work for any multi batch script for MSSQL Server. It even follows inserts without output. We were lucky I refactored decoder last winter so this was easy to expose
from tds.
@ekstrom BTW, please point your fork to tds master and run test, but there shouldn't be anything broken
from tds.
Tested it and it works as expected. Thanks for the good work 😄
from tds.
Related Issues (20)
- Getting MatchError even when passing correct credential HOT 10
- Ecto.Adapters.SQL.query/4 does not set correct type for parameters. HOT 7
- Need help with output parameter - SQL Server 2016 HOT 2
- Federated Auth HOT 3
- Implicit conversion from data type varbinary to date is not allowed HOT 18
- Current Status of this project? HOT 19
- Pull ntlm_auth to master HOT 3
- Support for Table Value Parameters in Tds adapter HOT 3
- Casting to nvarchar(max) returns nil results. HOT 4
- TLS connection error with OTP 25 HOT 5
- Image type support? HOT 9
- FunctionClauseError following a connection redirect HOT 3
- Azure Sql Database error NXDOMAIN HOT 1
- Bureaucracy HOT 2
- Geometry column type support HOT 8
- Connect to SQL server over TCP HOT 4
- Azure Redirect TCP connection closes every 2 minutes HOT 5
- Error connecting to local MSSQL database
- TDS and query prefixes to access several databases inside MSSQL HOT 1
- Ecto queries timeout when using the Ecto.Adapters.Tds adapter to query 10000 rows with columns of floating point numbers HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tds.