NAME
DBIO::MSSQL::Diff::View - Diff operations for MSSQL views
VERSION
version 0.900004
DESCRIPTION
CREATE OR ALTER VIEW for a view the classes declare that the database lacks or holds with another definition, DROP VIEW for a live view the classes do not declare. A view is kind => 'view' in the tables section of the model, with its stored text in definition (DBIO::MSSQL::Introspect::Views); a name schema.view is a view of that schema, quoted on both parts.
Every statement is a batch of its own for the server: CREATE VIEW has to be the only statement of its batch, and the deploy runs the statements one at a time. DBIO::MSSQL::Diff puts the drops before the tables are dropped and the creations after the tables, columns and keys exist.
Two definitions are the same when the text after AS is the same with its white space folded ("body"); the part before it (the name, a column list, WITH SCHEMABINDING) is not compared. A definition is never compared by case: a keyword written another way is another text.
METHODS
body
my $body = DBIO::MSSQL::Diff::View->body($definition);
The part of a stored definition after the AS of its header, trimmed, a trailing ; taken off, as written (white space inside is kept). The header is CREATE [OR ALTER] VIEW name [(columns)] [WITH options] AS; the AS is the first one outside brackets and double quotes after the name. A text that is no such header is its own body. undef gives undef.
normalize
The body with every run of white space folded to one blank. This is what two definitions are compared by.
diff
my @ops = DBIO::MSSQL::Diff::View->diff($source_tables, $target_tables);
The operations for the entries of the two tables sections that are views: create for a view of the target that the source lacks, alter for one both have whose bodies differ (when the source gives no definition it counts as different), drop for one of the source the target lacks. A declared view without a definition cannot be written and throws a DBIO::Exception. Creations and replacements come first, each view after the views it reads (depends_on of the model entry, from sys.sql_expression_dependencies), then the drops, each view before the views it reads; among views that do not read each other, by name. A cycle, or a view read that the model does not know, is refused (DBIO::Exception, "refused") before any statement is written.
as_sql
CREATE OR ALTER VIEW [schema].[name] AS body; for create and alter, DROP VIEW [schema].[name]; for drop.
summary
AUTHOR
DBIO & DBIx::Class Authors
COPYRIGHT AND LICENSE
Copyright (C) 2026 DBIO Authors Portions Copyright (C) 2005-2025 DBIx::Class Authors Based on DBIx::Class, heavily modified.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.