Crate lunatic_diesel
source ·Modules
Traits related to relationships between multiple tables.
Types which represent various database backends
Types related to database connections
Structs to represent the primitive equivalent of SQL types where
there is no existing Rust primitive, or where using it would be
confusing (such as date and time types). This module will re-export
all backend specific data structures when compiled against that
backend.
Types and traits related to deserializing values from the database
Includes various helper types and bare functions which are named too
generically to be included in prelude, but are often used when using Diesel.
AST types representing various typed SQL expressions.
Adds various methods to construct new expressions. These traits are exported
by default, and implemented automatically.
Provide helper types for concisely writing the return type of functions.
As with iterators, it is unfortunately difficult to return a partially
constructed query without exposing the exact implementation of the
function. Without higher kinded types, these various DSLs can’t be
combined into a single trait for boxing purposes.
Representation of migrations
Re-exports important traits and types. Meant to be glob imported when using Diesel.
Contains traits responsible for the actual construction of SQL statements
Traits that construct SELECT statements
Types related to describing schema, and interactions between tables.
Errors, type aliases, and functions related to working with
Result
.Contains the
Row
traitTypes and traits related to serializing values for the database
Types which represent a SQL data type.
Types and functions related to PG’s and Sqlite’s
ON CONFLICT
clauseMacros
Declare a new alias for a table
Allow two or more columns which are otherwise unrelated to be used together
in a group by clause.
Allow two or more tables which are otherwise unrelated to be used together
in a query.
Useful for libraries adding support for new SQL types. Apps should never
need to call this.
Allow two tables to be referenced in a join query without providing an
explicit
ON
clause.no_arg_sql_functionDeprecated
Declare a 0 argument SQL function for use in your code. This will generate a
unit struct, which is an expression representing calling this function. See
now
for example output. now
was
generated using:Indicates that an expression allows all numeric operators. If you create new
SQL functions that return a numeric type, you should invoke this macro that
type. Unfortunately, Rust disallows us from automatically implementing
Add
for types which implement Expression
, under its orphan rules.Implements the Rust operator for a given type. If you create a new SQL
function, which returns a type that you’d like to use an operator on, you
should invoke this macro. Unfortunately, Rust disallows us from
automatically implementing
Add
and other traits from std::ops
, under its
orphan rules.Useful for libraries adding support for new SQL types. Apps should never
need to call this.
Useful for libraries adding support for new SQL types. Apps should never
need to call this.
Declare a sql function for use in your code.
Specifies that a table exists, and what columns it has. This will create a
new public module, with the same name, as the name of the table. In this
module, you’ll find a unit struct named
table
, and a unit struct with the
names of each of the columns.Structs
Connections for the SQLite backend. Unlike other backends, SQLite supported
connection URLs are:
Enums
Errors which can occur during
Connection::establish
Traits
Indicates that all elements of an expression are valid given a from clause.
Types which can be passed to
update.set
.Constructs a query that finds record(s) based on directional association with other record(s).
Methods present on boolean expressions
Helper trait used when boxing expressions.
A column on a database table. Types which implement this trait should have
been generated by the
table!
macro.Extension trait to combine queries using a combinator like
UNION
, INTERSECT
or EXPECT
with or without ALL
rule for duplicatesA connection to a database
Interface to add information to conflict targets.
Designed to be open for further additions to conflict targets like constraints
Adds the
escape
method to LIKE
and NOT LIKE
. This is used to specify
the escape character for the pattern.Represents a typed fragment of SQL.
Methods present on all expressions, except tuples
The
grouped_by
function groups records by their parent.This trait indicates that a struct represents a single row in a database table.
Represents that a structure can be used to insert a new row into the
database. This is automatically implemented for
&[T]
and &Vec<T>
for
inserting more than one record.Converts a type to its representation for use in Diesel’s query builder.
Specify the
ON
clause for a join statement. This will override
any implicit ON
clause that would come from joinable!
Indicates that two tables can be joined without an explicit
ON
clause.Methods present on all expressions
Methods used to construct select statements.
Represents a type which can appear in the
FROM
clause. Apps should not
need to concern themselves with this trait.Trait indicating that a record can be queried from the database.
Deserializes the result of a query constructed with
sql_query
.Methods used to execute queries.
Sugar for types which implement both
AsChangeset
and Identifiable
Trait indicating that a record can be selected and queried from the database.
Indicates that an expression can be selected from a source.
This helper trait provides several methods for
constructing a select or returning clause based on a
Selectable
implementation.A SQL database table. Types which implement this trait should have been
generated by the
table!
macro.Methods present on text expressions
Functions
Takes a query
QueryFragment
expression as an argument and returns a type
that implements fmt::Display
and fmt::Debug
to show the query.Creates a
DELETE
statement.Creates an
INSERT
statement for the target table.Creates an
INSERT [OR] IGNORE
statement.Creates a
REPLACE
statement.Creates a bare select statement, with no from clause. Primarily used for
testing diesel itself, but likely useful for third party crates as well. The
given expressions must be selectable from anywhere.
Construct a full SQL query using raw SQL.
Creates an
UPDATE
statement.Type Definitions
A specialized result type for establishing connections.
A specialized result type for queries.
Derive Macros
Implements
AsChangeset
Implements all required variants of
AsExpression
Implement required traits for the associations API
Implement numeric operators for the current query node
Implements
Queryable
for primitive typesImplements
Identifiable
for references of the current typeImplements
Insertable
Implements
QueryId
Implements
Queryable
to load the result of statically typed queriesImplements
QueryableByName
for untyped sql queries, such as that one generated
by sql_query
Implements
Selectable
Implement necessary traits for adding a new sql type