-
Notifications
You must be signed in to change notification settings - Fork 564
Open
Labels
Description
Issue
Given an example schema:
create table posts
(
ID int identity,
Body varchar(max) not null,
)
go
create view popular_posts
as
select *
from postsstructure_dump generates the following file (which strips the Go statements added in between the various objects).
/* The object 'dbo.posts' does not have any indexes, or you do not have permissions. */
/* No constraints are defined on object 'dbo.posts', or you do not have permissions. */
/* No foreign keys reference table 'dbo.posts', or you do not have permissions on referencing tables. */
/* No views with schema binding reference table 'dbo.posts'. */
CREATE TABLE dbo.posts
( ID int NOT NULL
, Body varchar(-1) NOT NULL
)
CREATE VIEW popular_posts
AS
SELECT *
FROM postsAs a result, when loading the objects back into the database via structure_load, the following error is thrown.
$ rails db:setup
...
rails aborted!
ActiveRecord::StatementInvalid: TinyTds::Error: 'CREATE VIEW' must be the first statement in a query batch.
/Users/jonahgeorge/src/funcard/funcard/bin/rails:5:in `<top (required)>'
/Users/jonahgeorge/src/funcard/funcard/bin/spring:10:in `block in <top (required)>'
/Users/jonahgeorge/src/funcard/funcard/bin/spring:7:in `<top (required)>'
Expected behavior
structure_load should be capable of loading a structure.sql file generated by structure_dump.
Actual behavior
TinyTds::Error: 'CREATE VIEW' must be the first statement in a query batch. exception is raised.
Details
- Rails version:
6.1.4 - SQL Server adapter version:
v6.1.2.1 - FreeTDS details:
$ tsql -C
Compile-time settings (established with the "configure" script)
Version: freetds v1.3.3
freetds.conf directory: /opt/homebrew/etc
MS db-lib source compatibility: no
Sybase binary compatibility: yes
Thread safety: yes
iconv library: yes
TDS version: 7.3
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: yes
OpenSSL: yes
GnuTLS: no
MARS: yes