pub struct GeneratorContext { /* private fields */ }Implementations§
Source§impl GeneratorContext
impl GeneratorContext
pub fn new(settings: SqlGeneratorSettings, writer: SqlWriter) -> Self
Sourcepub fn for_model(
database_model: Rc<DatabaseModel>,
database_type: DatabaseType,
) -> Self
pub fn for_model( database_model: Rc<DatabaseModel>, database_type: DatabaseType, ) -> Self
Builds a context from just a model and dialect, with an in-memory output sink -
for callers (e.g. schema-migration-generator) that only need to call column-level
generator methods (column type / check constraint rendering), not run a full
CREATE TABLE generation. GenerateOptions::new’s default boolean_mode is
Native, so it’s overridden here from database_model.boolean_mode() - the model
always carries the real configured mode.
Sourcepub fn for_model_with_target_version(
database_model: Rc<DatabaseModel>,
database_type: DatabaseType,
target_version: u32,
) -> Self
pub fn for_model_with_target_version( database_model: Rc<DatabaseModel>, database_type: DatabaseType, target_version: u32, ) -> Self
Like for_model, but with a target dialect version (PostgreSQL major version, or SQL
Server product year) threaded through, for callers (e.g. schema-migration-generator)
that need version-gated column type SQL (e.g. json_sql) to match the dialect’s own
--postgresql-version/--sqlserver-version target. target_version is interpreted
per-dialect and ignored for DatabaseType::Sqlite, which has no version-gated types.
Sourcepub fn for_model_with_buffer(
database_model: Rc<DatabaseModel>,
database_type: DatabaseType,
) -> (Self, BufferSink)
pub fn for_model_with_buffer( database_model: Rc<DatabaseModel>, database_type: DatabaseType, ) -> (Self, BufferSink)
Like for_model, but with the in-memory sink exposed as a readable BufferSink
instead of a write-only, inaccessible Vec<u8> - for callers that need to invoke a
generator method (e.g. TriggerGenerator::output_triggers_for_table) for its
side-effecting writes and then read back what it produced.
Sourcepub fn for_model_with_buffer_and_target_version(
database_model: Rc<DatabaseModel>,
database_type: DatabaseType,
target_version: u32,
) -> (Self, BufferSink)
pub fn for_model_with_buffer_and_target_version( database_model: Rc<DatabaseModel>, database_type: DatabaseType, target_version: u32, ) -> (Self, BufferSink)
Like for_model_with_buffer, but with a target dialect version - see
for_model_with_target_version.