Comments (9)
Yea... this is a major problem and I'm inclined to think there is something special about your setup, else a LOT MORE people would be seeing this, including myself. Can you investigate that a bit more? What table name setting (if any) are you using in a particular AR model? Does this happen everywhere? SQL Server version? Etc etc. The more info the better.
from activerecord-sqlserver-adapter.
Reported by chagar | April 7th, 2009 @ 06:12 PM
When the model has set_table_name 'MYDATABASE.dbo.myTable', I get the following error, because the column_definitions method lacks a period in its query, or because unqualify_db_name is getting a database name that lacks a period.
Adding a single period in one place, makes it work.
The relevant line in column_definitions is:
FROM #{db_name}INFORMATION_SCHEMA.COLUMNS columns
Error message:
DBI::DatabaseError: S0002 (208) [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'MYDATABASEINFORMATION_SCHEMA.COLUMNS'.: SELECT columns.TABLE_NAME as table_name, columns.COLUMN_NAME as name, columns.DATA_TYPE as type, columns.COLUMN_DEFAULT as default_value, columns.NUMERIC_SCALE as numeric_scale, columns.NUMERIC_PRECISION as numeric_precision, CASE WHEN columns.DATA_TYPE IN ('nchar','nvarchar') THEN columns.CHARACTER_MAXIMUM_LENGTH ELSE COL_LENGTH(columns.TABLE_NAME, columns.COLUMN_NAME) END as length, CASE WHEN columns.IS_NULLABLE = 'YES' THEN 1 ELSE NULL end as is_nullable, CASE WHEN COLUMNPROPERTY(OBJECT_ID(columns.TABLE_NAME), columns.COLUMN_NAME, 'IsIdentity') = 0 THEN NULL ELSE 1 END as is_identity FROM MYDATABASEINFORMATION_SCHEMA.COLUMNS columns WHERE columns.TABLE_NAME = 'myTable' ORDER BY columns.ordinal_position
from activerecord-sqlserver-adapter.
sql server 2005, and we're always using the simple table name, like set_table_name 'foo'
from activerecord-sqlserver-adapter.
Us too... any idea why this is not working? Can you provide a patch and run the tests against it?
from activerecord-sqlserver-adapter.
there's a patch on the original lighthouse issue. take a look at that and let me know.
from activerecord-sqlserver-adapter.
I see this, http://gist.github.com/104210
But that does not tell me if there are tests and/or this has been tested with all the unit tests for the adapter/activerecord?
from activerecord-sqlserver-adapter.
I get the same error.
I presume the issue is that if a database name isn't specified the SQL code needs to be just:
FROM INFORMATION_SCHEMA.COLUMNS columns
Therefore add a private method:
def db_name_with_period(db_name)
"#{db_name}."
end
And then update the problem line to:
FROM #{db_name_with_period(db_name) if db_name}INFORMATION_SCHEMA.COLUMNS columns
from activerecord-sqlserver-adapter.
I fixed this in a few places that should wrap up this ticket.
http://github.com/rails-sqlserver/2000-2005-adapter/commit/b9e786b0435840d91681a3e998b15d67de2e5b59
from activerecord-sqlserver-adapter.
That should do it, and a neater alternative to my suggestion :o)
from activerecord-sqlserver-adapter.
Related Issues (20)
- ActiveRecord::ConnectionAdapters::SQLServerAdapter does not support upsert HOT 2
- Warning: undefining the allocator of T_DATA class TinyTds::Result HOT 1
- TinyTds::Error: Server name not found in configuration files HOT 1
- 7.0.2.0 identity insert issue
- Tests failing following release of Rails v7.0.5
- Rails 7.1 HOT 1
- Copyright missing the Copyright owner
- [Rails 7.1] Upgrading the MSSQL adapter HOT 7
- Migration to Create Stored Procedure Incorrectly Treated as an Insert Statement HOT 1
- NotNullViolation in boolean field of view HOT 7
- TinyTds::Error: Error converting data type varchar to numeric. HOT 6
- String default value not retrieved when using views HOT 4
- Tracking rails/solid_cache compatibility
- Default value read from another field HOT 1
- Is add_check_constraint supported? HOT 3
- `raw_connection_do` method removed in 7.1.0 but still referenced in Readme HOT 2
- Composite Primary Keys not being recognised HOT 2
- limit() method with subqueries HOT 3
- Tables that are in schemas other than `dbo` are not properly reproduced in schema.rb HOT 1
- exclude_output_inserted_table_names does not support composite primary keys with different data types
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from activerecord-sqlserver-adapter.