Closed rpcolom closed 2 months ago
Could you create a test-case using the script in https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki/How-to-report-a-bug#minimal-reproducible-script to reproduce the issue?
Hi Aidanharan!!
I've added the test to check the issue. For you notice, this tablename is tipical for Microsoft ERP Navision/BC.
Thanks!! Rafa
Issue fixed in Release v7.1.5.
Issue
On a SELECT stmt the generate SQL string is correct. But on INSERT stmt dont get the INSERT SQL string correct with token table
Expected behavior
dbo.[2 - SOME$Contact]
Actual behavior
ActiveRecord::StatementInvalid: Table '[dbo].[2' doesn't exist
How to reproduce
require "bundler/inline"
gemfile(true) do source "https://rubygems.org" gem "tiny_tds" gem "activerecord", "7.1.3.4" gem "activerecord-sqlserver-adapter", "7.1.4" end
require "active_record" require "minitest/autorun" require "logger"
ActiveRecord::Base.establish_connection( adapter: "sqlserver", timeout: 5000, pool: 100, encoding: "utf8", database: "test_database", username: "SA", password: "StrongPassword!", host: "localhost", port: 1433 ) ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do drop_table "[2 - SOME$TABLENAME]" rescue nil
create_table "[2 - SOME$TABLENAME]", force: true do |t| t.bigint :external_id, null: false end end
class BugTest < ActiveRecord::Base self.table_name = "[2 - SOME$TABLENAME]" end
class TestBugTest < Minitest::Test def setup @bug_test = BugTest.create!(external_id: 10) end
def test_count assert_equal 1, BugTest.count end end
Details
7.1.3.4
7.1.4
2.1.7
FreeTDS details:
1.4.17