Commit Graph

51 Commits

Author SHA1 Message Date
gwenn
5730b2f952 Fix clippy warnings 2021-06-25 18:57:25 -07:00
gwenn
df02910660
Implement AsRef<Statement> for Row(s) (#887) 2021-05-26 14:51:28 +02:00
gwenn
cd40cc330b
Rustfmt (#956) 2021-05-07 19:39:53 +02:00
Dirk Stolle
c33d6bfad3 fix several typos 2021-05-02 23:03:10 -07:00
gwenn
c4b398f468
Doctest column name reference (#918)
* Doctest column name reference
* Document rusqlite assumption on column name reference
And move doctest as a test.
* Document when columns metadata should be extracted.
* Rustfmt doc (wrap_comments)
2021-04-03 11:03:50 +02:00
gwenn
e154ccb606
Rename get_raw to get_ref_unwrap and get_raw_checked to get_ref (#838)
* test `From<FromSqlError> for Error`
* Rename get_raw to get_ref_unwrap and get_raw_checked to get_ref
2020-12-22 21:34:30 +01:00
gwenn
6fae5d6641 Add/fix rustdoc links 2020-11-22 09:34:03 +01:00
gwenn
da94f8eba6 Make tests return Result 2020-11-05 22:14:00 +01:00
Thom Chiovoloni
65c38bf813 Add #[inline] and #[cold] in far more places 2020-11-04 07:59:23 -08:00
Thom Chiovoloni
22121772a2 Deprecate NO_PARAMS in favor of passing an empty array 2020-11-03 19:09:19 -08:00
Thom Chiovoloni
032aea73b8 Overhaul query API, removing the need for the _named variants of all functions, and rusqlite::NO_PARAMS 2020-11-03 19:09:19 -08:00
Thom Chiovoloni
c45446ba73 Seal the RowIndex trait (technically breaking, but unlikely to break anybody) 2020-11-03 19:09:19 -08:00
Michael Sproul
d7e0536b41
Add must_use attribute to iterators 2020-09-02 16:15:25 +10:00
gwenn
7b08dc9ad5 Try to explain why we need a map function
To tranform the fallible streaming iterator.
2020-06-02 19:05:09 +02:00
gwenn
8cb5b2e585 Document Rows::map and FallibleStreamingIterator impl
See
https://www.reddit.com/r/rust/comments/gov817/rusqlite_only_getting_ok_entries_from_query_map/
```
let mut stmt = self
    .db
    .prepare("SELECT tag FROM tags WHERE tags.entry_id = ?1")?;

let tags = stmt.query(params![id])?;

tags
    .map(|res| res.get(0))
    .collect()
```
2020-05-24 20:53:52 +02:00
gwenn
76fc22c653 Fix missing docs 2020-05-21 00:48:06 -07:00
Martin Habovstiak
8a08dff115 Clippy reports redundant closures even in cases in which removing the
closure is impossible. See
https://github.com/rust-lang/rust-clippy/issues/5594

Allow this lint until the issue is resolved in clippy or the compiler.
2020-05-21 00:47:52 -07:00
Martin Habovstiak
c5b2efc099 impl TryFrom<&Row<'_>> for (...)
This change implements `TryFrom<&Row>` for tuples up to 16 fields. This
is a convenience function that can be used to map rows more easily.

The change includes tests for 1-tuple, 2-tuple and 16-tuple.
2020-05-21 00:47:52 -07:00
Thom Chiovoloni
d35dd0e99f
Allow optionally passing an Error parameter to rusqlite::Result (#678) 2020-04-06 14:43:06 -07:00
Thom Chiovoloni
9b040da029
Add Rows::{mapped,and_then} to get an Iterator out of a Rows i… (#676) 2020-04-06 13:01:39 -07:00
gwenn
9ce3b82570 Make column_name returns a Result 2019-08-31 12:17:48 +02:00
Pro
d46eb23364 Make column_name() public
Changes it's interface to Option<&str> to accommodate for out of bounds index
2019-08-22 16:38:43 +02:00
gwenn
208f3c084b Clippy: fix warnings 2019-07-10 21:10:12 +02:00
Thom Chiovoloni
4356f5a176 Include the name of the column in InvalidColumnType errors 2019-06-25 12:20:11 -07:00
Simon Bernier St-Pierre
c42175a424 add support for Uuid 2019-04-08 14:19:42 -04:00
gwenn
80205da623 Rustfmt + clippy 2019-03-21 19:13:55 +01:00
gwenn
38e92159fb Introduce Statement::columns
Return Columns name and type. (#494)
2019-03-19 20:33:36 +01:00
gwenn
71a2004894 Add Rows::map method 2019-03-10 12:58:20 +01:00
gwenn
59a44cfae5 Merge remote-tracking branch 'jgallagher/master' into fallible-iterator 2019-03-10 11:12:14 +01:00
gwenn
6d9ae896b5 Do not panic by default
Replace `Row::get` by `Row::get_checked`,
And rename original `Row::get` to `Row::get_unwrap`.
`Stmt::query_map`, `Stmt::query_map_named`, `Stmt::query_row`,
`Conn::query_row` and `Conn::query_row_named` callback parameter must return a `Result`.
2019-02-21 20:48:09 +01:00
gwenn
2c1483f2e7 Merge remote-tracking branch 'jgallagher/master' into fallible-iterator 2019-02-09 06:47:57 +01:00
gwenn
7c5bfb7cc3
Merge pull request #475 from gwenn/db-config
Support for sqlite3_db_config #468
2019-02-08 21:38:01 +01:00
gwenn
d93dec52c0 Make Rows implement FallibleStreamingIterator 2019-02-03 14:01:42 +01:00
gwenn
e9896a7734 Lifetime elision in impl 2019-02-03 11:02:38 +01:00
gwenn
519ef9dc84 Fix rustdoc warnings 2019-02-02 15:18:11 +01:00
gwenn
d874180333 Rust 2018 idioms 2018-12-07 21:57:04 +01:00
gwenn
dc49b28520 Fix some clippy warnings 2018-12-06 19:00:55 +01:00
gwenn
f04047db01 Rust 2018 2018-10-30 20:15:08 +01:00
gwenn
1598d4bc30 Rustfmt 2018-10-28 08:51:02 +01:00
gwenn
0d08bf5e05
Merge pull request #411 from thomcc/i128_blob
Add a feature for storing i128 as blobs.
2018-10-19 21:49:09 +02:00
Thom Chiovoloni
3d82f7199a Allow getting a ValueRef out of Row and Context, fixes #259 2018-10-18 12:14:38 -07:00
Thom Chiovoloni
572471c40f Add a feature for storing i128 as blobs.
This is behind the `i128_blob` feature.

Blobs are stored as 16 byte big-endian values, with their most significant bit
flipped. This is so that sorting, comparison, etc all work properly, even with
negative numbers. This also allows the representation to be stable across
different computers.

It's possible that the `FromSql` implementation should handle the case that the
real value is stored in an integer. I didn't do this, but would be willing to
make the change. I don't think we should store them this way though, since I
don't think users would be able to sort/compare them sanely.

Support for `u128` is not implemented, as comparison with i128 values would work
strangely. This also is consistent with `u64` not being allowed, not that I
think that would be reason enough on it's own.

The `byteorder` crate is used if this feature is flipped, as it's quite small
and implements things more or less optimally. If/when `i128::{to,from}_be_bytes`
gets stabilized (https://github.com/rust-lang/rust/issues/52963), we should
probably use that instead.
2018-10-08 12:22:28 -07:00
gwenn
5e9c7bac4e Rustfmt 2018-08-16 18:29:46 +02:00
gwenn
c925d1aa97 Rustfmt 2018-08-11 12:48:21 +02:00
gwenn
7310cac6f5 Use pub(crate) 2018-07-31 22:17:17 +02:00
gwenn
9c7a5583b9 Fix some clippy warnings
* Rows cannot implement iterator
* DatabaseName is passed by value => Copy ?
2018-06-20 19:07:23 +02:00
gwenn
c6f4ae632a Replace column index/count type (i32) with usize
Breaking change
2018-05-23 21:04:13 +02:00
gwenn
994d40da26 Fix clippy warnings 2018-05-04 19:55:55 +02:00
king6cong
13a32e4004 code indent 2017-06-02 17:19:39 +08:00
gwenn
08f96a678e Rustfmt 2017-04-07 19:43:24 +02:00