seems to resolve some compiler errors

This commit is contained in:
Conrad Dean 2019-07-17 11:46:47 -04:00
parent 3d965fdf6e
commit b6b316953e
6 changed files with 2033 additions and 1093 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -205,15 +205,15 @@ pub fn datoms_after<S: Borrow<Schema>>(conn: &rusqlite::Connection, schema: &S,
let mut stmt: rusqlite::Statement = conn.prepare("SELECT e, a, v, value_type_tag, tx FROM datoms WHERE tx > ? ORDER BY e ASC, a ASC, value_type_tag ASC, v ASC, tx ASC")?;
let r: Result<Vec<_>> = stmt.query_and_then(&[&tx], |row| {
let e: i64 = row.get_checked(0)?;
let a: i64 = row.get_checked(1)?;
let e: i64 = row.get(0)?;
let a: i64 = row.get(1)?;
if a == entids::DB_TX_INSTANT {
return Ok(None);
}
let v: rusqlite::types::Value = row.get_checked(2)?;
let value_type_tag: i32 = row.get_checked(3)?;
let v: rusqlite::types::Value = row.get(2)?;
let value_type_tag: i32 = row.get(3)?;
let attribute = borrowed_schema.require_attribute_for_entid(a)?;
let value_type_tag = if !attribute.fulltext { value_type_tag } else { ValueType::Long.value_type_tag() };
@ -221,7 +221,7 @@ pub fn datoms_after<S: Borrow<Schema>>(conn: &rusqlite::Connection, schema: &S,
let typed_value = TypedValue::from_sql_value_pair(v, value_type_tag)?.map_ident(borrowed_schema);
let (value, _) = typed_value.to_edn_value_pair();
let tx: i64 = row.get_checked(4)?;
let tx: i64 = row.get(4)?;
Ok(Some(Datom {
e: EntidOrIdent::Entid(e),
@ -245,11 +245,11 @@ pub fn transactions_after<S: Borrow<Schema>>(conn: &rusqlite::Connection, schema
let mut stmt: rusqlite::Statement = conn.prepare("SELECT e, a, v, value_type_tag, tx, added FROM transactions WHERE tx > ? ORDER BY tx ASC, e ASC, a ASC, value_type_tag ASC, v ASC, added ASC")?;
let r: Result<Vec<_>> = stmt.query_and_then(&[&tx], |row| {
let e: i64 = row.get_checked(0)?;
let a: i64 = row.get_checked(1)?;
let e: i64 = row.get(0)?;
let a: i64 = row.get(1)?;
let v: rusqlite::types::Value = row.get_checked(2)?;
let value_type_tag: i32 = row.get_checked(3)?;
let v: rusqlite::types::Value = row.get(2)?;
let value_type_tag: i32 = row.get(3)?;
let attribute = borrowed_schema.require_attribute_for_entid(a)?;
let value_type_tag = if !attribute.fulltext { value_type_tag } else { ValueType::Long.value_type_tag() };
@ -257,8 +257,8 @@ pub fn transactions_after<S: Borrow<Schema>>(conn: &rusqlite::Connection, schema
let typed_value = TypedValue::from_sql_value_pair(v, value_type_tag)?.map_ident(borrowed_schema);
let (value, _) = typed_value.to_edn_value_pair();
let tx: i64 = row.get_checked(4)?;
let added: bool = row.get_checked(5)?;
let tx: i64 = row.get(4)?;
let added: bool = row.get(5)?;
Ok(Datom {
e: EntidOrIdent::Entid(e),
@ -279,8 +279,8 @@ pub fn fulltext_values(conn: &rusqlite::Connection) -> Result<FulltextValues> {
let mut stmt: rusqlite::Statement = conn.prepare("SELECT rowid, text FROM fulltext_values ORDER BY rowid")?;
let r: Result<Vec<_>> = stmt.query_and_then(&[], |row| {
let rowid: i64 = row.get_checked(0)?;
let text: String = row.get_checked(1)?;
let rowid: i64 = row.get(0)?;
let text: String = row.get(1)?;
Ok((rowid, text))
})?.collect();
@ -305,7 +305,7 @@ pub fn dump_sql_query(conn: &rusqlite::Connection, sql: &str, params: &[&ToSql])
let r: Result<Vec<_>> = stmt.query_and_then(params, |row| {
for i in 0..row.column_count() {
let value: rusqlite::types::Value = row.get_checked(i)?;
let value: rusqlite::types::Value = row.get(i)?;
write!(&mut tw, "{:?}\t", value).unwrap();
}
write!(&mut tw, "\n").unwrap();

View file

@ -61,7 +61,7 @@ use watcher::{
fn collect_ordered_txs_to_move(conn: &rusqlite::Connection, txs_from: RangeFrom<Entid>, timeline: Entid) -> Result<Vec<Entid>> {
let mut stmt = conn.prepare("SELECT tx, timeline FROM timelined_transactions WHERE tx >= ? AND timeline = ? GROUP BY tx ORDER BY tx DESC")?;
let mut rows = stmt.query_and_then(&[&txs_from.start, &timeline], |row: &rusqlite::Row| -> Result<(Entid, Entid)>{
Ok((row.get_checked(0)?, row.get_checked(1)?))
Ok((row.get(0)?, row.get(1)?))
})?;
let mut txs = vec![];
@ -106,7 +106,7 @@ fn remove_tx_from_datoms(conn: &rusqlite::Connection, tx_id: Entid) -> Result<()
fn is_timeline_empty(conn: &rusqlite::Connection, timeline: Entid) -> Result<bool> {
let mut stmt = conn.prepare("SELECT timeline FROM timelined_transactions WHERE timeline = ? GROUP BY timeline")?;
let rows = stmt.query_and_then(&[&timeline], |row| -> Result<i64> {
Ok(row.get_checked(0)?)
Ok(row.get(0)?)
})?;
Ok(rows.count() == 0)
}
@ -115,15 +115,15 @@ fn is_timeline_empty(conn: &rusqlite::Connection, timeline: Entid) -> Result<boo
fn reversed_terms_for(conn: &rusqlite::Connection, tx_id: Entid) -> Result<Vec<TermWithoutTempIds>> {
let mut stmt = conn.prepare("SELECT e, a, v, value_type_tag, tx, added FROM timelined_transactions WHERE tx = ? AND timeline = ? ORDER BY tx DESC")?;
let mut rows = stmt.query_and_then(&[&tx_id, &::TIMELINE_MAIN], |row| -> Result<TermWithoutTempIds> {
let op = match row.get_checked(5)? {
let op = match row.get(5)? {
true => OpType::Retract,
false => OpType::Add
};
Ok(Term::AddOrRetract(
op,
KnownEntid(row.get_checked(0)?),
row.get_checked(1)?,
TypedValue::from_sql_value_pair(row.get_checked(2)?, row.get_checked(3)?)?,
KnownEntid(row.get(0)?),
row.get(1)?,
TypedValue::from_sql_value_pair(row.get(2)?, row.get(3)?)?,
))
})?;

View file

@ -98,7 +98,7 @@ impl SyncMetadata {
PartitionsTable::Tolstoy => {
let mut stmt: ::rusqlite::Statement = tx.prepare("SELECT part, start, end, idx, allow_excision FROM tolstoy_parts")?;
let m: Result<PartitionMap> = stmt.query_and_then(&[], |row| -> Result<(String, Partition)> {
Ok((row.get_checked(0)?, Partition::new(row.get_checked(1)?, row.get_checked(2)?, row.get_checked(3)?, row.get_checked(4)?)))
Ok((row.get(0)?, Partition::new(row.get(1)?, row.get(2)?, row.get(3)?, row.get(4)?)))
})?.collect();
m
}
@ -108,7 +108,7 @@ impl SyncMetadata {
pub fn root_and_head_tx(tx: &rusqlite::Transaction) -> Result<(Entid, Entid)> {
let mut stmt: ::rusqlite::Statement = tx.prepare("SELECT tx FROM timelined_transactions WHERE timeline = 0 GROUP BY tx ORDER BY tx")?;
let txs: Vec<_> = stmt.query_and_then(&[], |row| -> Result<Entid> {
Ok(row.get_checked(0)?)
Ok(row.get(0)?)
})?.collect();
let mut txs = txs.into_iter();
@ -131,7 +131,7 @@ impl SyncMetadata {
};
let mut stmt: ::rusqlite::Statement = db_tx.prepare(&format!("SELECT tx FROM timelined_transactions {} GROUP BY tx ORDER BY tx", after_clause))?;
let txs: Vec<_> = stmt.query_and_then(&[], |row| -> Result<Entid> {
Ok(row.get_checked(0)?)
Ok(row.get(0)?)
})?.collect();
let mut all = Vec::with_capacity(txs.len());
@ -144,14 +144,14 @@ impl SyncMetadata {
pub fn is_tx_empty(db_tx: &rusqlite::Transaction, tx_id: Entid) -> Result<bool> {
let count = db_tx.query_row("SELECT count(rowid) FROM timelined_transactions WHERE timeline = 0 AND tx = ? AND e != ?", &[&tx_id, &tx_id], |row| -> Result<i64> {
Ok(row.get_checked(0)?)
Ok(row.get(0)?)
})?;
Ok(count? == 0)
}
pub fn has_entity_assertions_in_tx(db_tx: &rusqlite::Transaction, e: Entid, tx_id: Entid) -> Result<bool> {
let count = db_tx.query_row("SELECT count(rowid) FROM timelined_transactions WHERE timeline = 0 AND tx = ? AND e = ?", &[&tx_id, &e], |row| -> Result<i64> {
Ok(row.get_checked(0)?)
Ok(row.get(0)?)
})?;
Ok(count? > 0)
}

View file

@ -118,11 +118,11 @@ where T: Sized + Iterator<Item=Result<TxPart>> + 't {
fn to_tx_part(row: &rusqlite::Row) -> Result<TxPart> {
Ok(TxPart {
partitions: None,
e: row.get_checked(0)?,
a: row.get_checked(1)?,
v: TypedValue::from_sql_value_pair(row.get_checked(2)?, row.get_checked(3)?)?,
tx: row.get_checked(4)?,
added: row.get_checked(5)?,
e: row.get(0)?,
a: row.get(1)?,
v: TypedValue::from_sql_value_pair(row.get(2)?, row.get(3)?)?,
tx: row.get(4)?,
added: row.get(5)?,
})
}