Expand description
Contains all SQL queries as constants with placeholders A centralized repository for all static SQL query strings used throughout the application.
This module acts as a single source of truth for database queries, decoupling the raw SQL from the application’s business logic. This design offers several key advantages:
- Centralization: All queries are in one place, making them easy to find, review, and manage.
- Maintainability: If a table or column name changes, it only needs to be updated here, rather than in multiple places across the codebase.
- Security Auditing: Having all queries in one file simplifies the process of auditing for potential security vulnerabilities like SQL injection.
- Decoupling: Rust code that interacts with the database can focus on logic without being cluttered with long, embedded SQL strings.
§Usage
Queries are defined as pub const &str. They use named parameters (e.g., :my_param)
which are compatible with the mysql crate’s params! macro for safe data binding.
Constants§
- SQL_
QUERY_ CHECK_ BALLING_ DOSING_ LOG_ COUNT - Checks how many entries are in the balling dosing log
- SQL_
QUERY_ CHECK_ BALLING_ SETVALS_ COUNT - Checks how many entries are in the balling set value table
- SQL_
QUERY_ CHECK_ BALLING_ SETVALS_ NULL - Checks if the balling set value table contains any NULL values.
- SQL_
QUERY_ CHECK_ DATA_ COUNT - Checks how many entries there are in the data table.
- SQL_
QUERY_ CHECK_ FEEDLOG_ COUNT - Checks how many entries there are in the feed log table.
- SQL_
QUERY_ CHECK_ FEEDPATTERNS_ NULL - Checks if the feed patterns table contains any NULL values.
- SQL_
QUERY_ CHECK_ FEEDPATTERN_ COUNT - Checks how many entries there are in the feed patterns table.
- SQL_
QUERY_ CHECK_ FEEDSCHEDULE_ COUNT - Checks how many entries there are in the feed schedule table.
- SQL_
QUERY_ CHECK_ FEEDSCHEDULE_ NULL - Checks if the feed schedule table contains any NULL values.
- SQL_
QUERY_ CHECK_ HEATING_ SETVALS_ COUNT - Checks how many entries there are in the heating set value table.
- SQL_
QUERY_ CHECK_ HEATING_ SETVALS_ NULL - Checks if the heating set value table contains any NULL values.
- SQL_
QUERY_ CHECK_ HEATING_ STATS_ COUNT - Checks how many entries there are in the heating set value table.
- SQL_
QUERY_ CHECK_ HEATING_ STATS_ NULL - Checks if the heating stats table contains any NULL values.
- SQL_
QUERY_ CHECK_ REFILL_ COUNT - Checks how many entries there are in the refill table.
- SQL_
QUERY_ CHECK_ REFILL_ EMPTY - Checks if the refill table is empty.
- SQL_
QUERY_ CHECK_ SCHEDULE_ COUNT - Checks how many entries there are in the schedule table.
- SQL_
QUERY_ CHECK_ SCHEDULE_ NULL - Checks if the schedule table contains any NULL values.
- SQL_
QUERY_ CHECK_ VENTILATION_ SETVALS_ COUNT - Checks how many entries there are in the heating set value table.
- SQL_
QUERY_ CHECK_ VENTILATION_ SETVALS_ NULL - SQL_
QUERY_ DATABASE - Provides the current database name.
- SQL_
QUERY_ DELETE_ FEED_ SCHEDULE_ ENTRY - Updates a feed schedule entry after having executing a feed pattern which shall not be repeated daily.
- SQL_
QUERY_ PING - Minimal request to the database to avoid timeouts
- SQL_
QUERY_ READ_ BALLING_ SETVALS - Provides the Balling dosing pump configuration for one of the pumps.
- SQL_
QUERY_ READ_ CURRENT_ DATE - Provides the current date (without time) from the database.
- SQL_
QUERY_ READ_ CURRENT_ TIMESTAMP - Provides the current timestamp from the database.
- SQL_
QUERY_ READ_ DURATION_ UNTIL_ MIDNIGHT - Provides the duration in seconds until midnight from the database.
- SQL_
QUERY_ READ_ FEEDPATTERN_ HEADER - Provides the header of a feed pattern from the database.
- SQL_
QUERY_ READ_ FEED_ PHASE - Provides one phase of a feed pattern from the database.
- SQL_
QUERY_ READ_ HEATING_ SETVALS - Reads the heating set values from the database.
- SQL_
QUERY_ READ_ HEATING_ STATS - Provides the heating statistical data of the current day from the database.
- SQL_
QUERY_ READ_ LAST_ BALLING_ DOSING_ TIMESTAMP - Provides the timestamp of the last Balling dosing event from the database.
- SQL_
QUERY_ READ_ LAST_ REFILL_ TIMESTAMP - Provides the timestamp of the last refill event from the database.
- SQL_
QUERY_ READ_ PAST_ FEED_ SCHEDULE_ ENTRY - Provides the feed schedule entries which lie in the past in descending order
- SQL_
QUERY_ READ_ REFILL_ COUNT_ LAST_ 24H - Provides the number of refill events from the last day from the database.
- SQL_
QUERY_ READ_ REFILL_ COUNT_ LAST_ HOUR - Provides the number of refill events from the last hour from the database. It does not need to use the COALESCE function because the query returns 0 if there is no refill event in the last 24h.
- SQL_
QUERY_ READ_ REFILL_ VOLUME_ LAST_ 24H - Provides the refill volume of the last day from the database. It needs to use the COALESCE function because a null result is not interpreted correctly by the SQL library.
- SQL_
QUERY_ READ_ REFILL_ VOLUME_ LAST_ HOUR - Provides the refill volume of the last hour from the database. It needs to use the COALESCE function because a null result is not interpreted correctly by the SQL library.
- SQL_
QUERY_ READ_ SCHEDULE - Provides the schedule entry for one of the controls (Refill, Ventilation, Heating, Balling)
- SQL_
QUERY_ READ_ TABLES - Provides all tables from the database. This query cannot be limited.
- SQL_
QUERY_ READ_ TIMEOUT - Provides the system variable that controls how long the server waits for activity on an idle connection before closing it.
- SQL_
QUERY_ READ_ TOMORROW_ DATE - Provides tomorrow’s date (without time) from the database.
- SQL_
QUERY_ READ_ VENTILATION_ SETVALS - Reads the ventilation set values from the database.
- SQL_
QUERY_ UPDATE_ FEED_ SCHEDULE_ ENTRY - Updates a feed schedule entry after having executing a feed pattern which shall be repeated daily.
- SQL_
QUERY_ VERSION_ INFORMATION - Provides version information to check if the current application is listed in the table of supported versions. It informs whether the version is supported and which hash is stored in the database for the version.
- SQL_
QUERY_ WRITE_ BALLING_ EVENT - Writes the last Balling dosing event to the database.
- SQL_
QUERY_ WRITE_ DATA - Writes the time-based data into the database.
- SQL_
QUERY_ WRITE_ FEED_ EVENT - Inserts data of one feed event into the database.
- SQL_
QUERY_ WRITE_ HEATING_ STATS - Writes the heating statistical data into the database. If there is already data for the given date, the data will not be inserted. Instead, the existing entry will be updated.
- SQL_
QUERY_ WRITE_ REFILL_ EVENT - Writes the last refill event to the database.
- SQL_
TABLE_ FEEDLOG - Definition of table name for feed log
- SQL_
TABLE_ FEEDPATTERNS - Definition of table name for feed patterns
- SQL_
TABLE_ FEEDSCHEDULE - Definition of table name for feed schedule