Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    John Koisch
    as near as I can tell via roles and permissions, the dbUser has access to the Information_SCHEMA. Is there some way to check?
    Ken Collins
    Not that I know of off hand. But I can say that is your issue.
    Dig a bit.
    John Koisch

    digging a lot ... through SMMS, this query returns 44 table names that are present in the dbo schema

    SELECT t.name
    FROM sys.tables AS t
    INNER JOIN sys.schemas AS s
    ON t.[schema_id] = s.[schema_id]
    WHERE s.name = N'dbo';

    this is true regardless of what database I hit (prod 1, prod2, dev 1, etc)

    when I run that from rails c, i get

    irb(main):006:0> results = Location.connection.exec_query("SELECT t.name FROM sys.tables AS t INNER JOIN sys.schemas AS s ON t.[schema_id] = s.[schema_id] WHERE s.name = N'dbo'")
    SQL (25.5ms) SELECT t.name FROM sys.tables AS t INNER JOIN sys.schemas AS s ON t.[schema_id] = s.[schema_id] WHERE s.name = N'dbo'
    => #<ActiveRecord::Result:0x007fe390734800 @columns=["name"], @rows=[["spt_fallback_db"], ["spt_fallback_dev"], ["spt_fallback_usg"], ["spt_monitor"]], @hash_rows=nil, @column_types={}>

    when pointing to the prod database where the query is failing. When I run it on the prod database where the Location query works, it sees all 44 tables as expected.

    So, ultimately, i agree ... it is a perms issue.

    Syed Faraaz Ahmad
    does tiny_tds work for ruby 2.5?
    Dov s
    Hi, I am a beginner programmer and new to ruby on rails. I am trying to deploy a ruby on rails app with sql server using tiny_tds. It works locally using an azure sql server db but I am unable to deploy to an azure web app with tiny_tds. It seems as though the freetds library needs to be on the azure web app before installing the tiny_tds gem. This is the error I get when I push to azure: remote: Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
    remote: current directory: /tmp/bundle/gems/tiny_tds-2.1.1/ext/tiny_tds
    remote: /usr/local/.rbenv/versions/2.3.3/bin/ruby -r ./siteconf20180314-3087-2d24bj.rb
    remote: extconf.rb
    remote: checking for sybfront.h... yes
    remote: checking for sybdb.h... yes
    remote: checking for tdsdbopen() in -lsybdb... yes
    remote: checking for dbanydatecrack() in -lsybdb... no
    remote: Failed! Do you have FreeTDS 0.95.80 or higher installed?
    remote: extconf.rb failed
    remote: Could not create Makefile due to some reason, probably lack of necessary
    remote: libraries and/or headers. Check the mkmf.log file for more details. You may
    remote: need configuration options.
    remote: Provided configuration options:
    remote: --with-opt-dir
    remote: --without-opt-dir
    remote: --with-opt-include
    remote: --without-opt-include=${opt-dir}/include
    remote: --with-opt-lib
    remote: --without-opt-lib=${opt-dir}/lib
    remote: --with-make-prog
    remote: --without-make-prog
    remote: --srcdir=.
    remote: --curdir
    remote: --ruby=/usr/local/.rbenv/versions/2.3.3/bin/$(RUBY_BASE_NAME)
    remote: --help
    remote: --with-freetds-dir
    remote: --without-freetds-dir
    remote: --with-freetds-include
    remote: --without-freetds-include=${freetds-dir}/include
    remote: --with-freetds-lib
    remote: --without-freetds-lib=${freetds-dir}/lib
    remote: --with-freetds-dir
    remote: --without-freetds-dir
    remote: --with-freetds-include
    remote: --without-freetds-include=${freetds-dir}/include
    remote: --with-freetds-lib
    remote: --without-freetds-lib=${freetds-dir}/lib
    remote: --with-sybdblib
    remote: --without-sybdblib
    remote: --with-sybdblib
    remote: --without-sybdblib
    remote: To see why this extension failed to compile, please check the mkmf.log which can
    remote: be found here:
    remote: /tmp/bundle/extensions/x86_64-linux/2.3.0-static/tiny_tds-2.1.1/mkmf.log
    remote: extconf failed, exit code 1
    remote: Gem files will remain installed in /tmp/bundle/gems/tiny_tds-2.1.1 for
    remote: inspection.
    remote: Results logged to
    remote: /tmp/bundle/extensions/x86_64-linux/2.3.0-static/tiny_tds-2.1.1/gem_make.out
    remote: An error occurred while installing tiny_tds (2.1.1), and Bundler cannot
    remote: continue.
    remote: Make sure that gem install tiny_tds -v '2.1.1' succeeds before bundling.
    remote: An error has occurred during web site deployment.
    remote: bundler failed
    Is there a way to make new versions of the gem (compatible with rails 5) also compatible with an old sql server? We're rewriting an ancient application on rails 5 and would like to have both versions running in parallel during development. The old application runs off of a 2005 MSSQL Server, while our newer sql db is 2012. We are eventually planning on migrating everything to the new DB, but the old app is rails 2 and can't connect to SQL Server 2012. We'd like to avoid migrating both the sql server and the rails app at the same time if we can avoid it
    Ryan Condron
    I am digging through the changes between 5.1 & 5.2 and i have started to compile a list of changes just trying to get the tests to run, I am not sure opening issues is the best since these are pretty basic, i.e. removed files from ActiveRecord or Arel that are referenced.
    Renato Marinho
    This message was deleted
    Aymeric Maire
    hi there
    Renato Marinho
    This message was deleted
    Jeffrey M Castro

    hello guys, i have a question about the limit method as i am having an issue with pagination.

    the code records.page(1).limit(10)
    gives this sql command: ... [users].[id] IN (1, 2, 3, 4, 9, 3, 5, 8, 10, 6)

    notice that the ID = 3 is used twice.. resulting in incorrect pagination (returning 9 records instead of 10), any help is appreciated on how to fix this.

    i am using rails 5.1.4 with docker image for mssqlserver 2017
    Bobby McDonald
    Is there a way to configure the adapter to not use every table in the connected database?
    Bobby McDonald
    Why does the adapter run a query to get a default value again, when it should already be there from this line of code
    @jeffreycastro could you pleas give us some more infos? what is "records" and why is it selecting on "users"?
    @BobbyMcWho The adapter uses no tables, its your code which accesses tables.
    Jeffrey M Castro
    @KDGundermann thanks for taking time to read my message, i will get back to you on this tomorrow :)
    Jeffrey M Castro

    @KDGundermann I think the reason is the "includes" vs "left_joins".
    Device.left_joins(:health_records).order('health_records.error_number desc').page(1).limit(10).count returns 10

    Device.includes(:health_records).order('health_records.error_number desc').page(1).limit(10).count returns 3

    the only difference is includes and left_joins in the queries above. can you explain to me why?
    Jeffrey M Castro
    i think i got it now.
    used left_joins and subqueries + select to be able to order properly.
    Tushar Pal
    Hi anyone here
    how is going the progress to run this gem on rails 5.2?
    running ruby 2.4.0 and following a tutorial. Getting undefined method `alias_method_chain' for #<Class:ActiveRecord::Base> (NoMethodError) Everytime I require this gem
    ok nvm
    figured it out. I had to clear my local gemset in rvm and lock my active record to ~>5.1
    then install the other gems
    I need to set up a connection with sql server 2008 in rails
    all I want to make is a direct sql connection that I can write sql queries
    I have the database credentials
    would need 1. set up the database connection, 2. sql interface to database
    Benjamin Fleischer
    Going from version 4.2.18 to 5.0.8 (We're of course also upgrading Rails) has broker finder behavior on a table with multiple primary keys, and I'm not sure how to address it. For exampleMyRecord.where(field_name: value).take now fails with ActiveRecord::StatementInvalid:
    TinyTds::Error: Invalid column name '"TicketNo", "UniqueID", "ItemNo"'.: EXEC sp_executesql N'SELECT [Tkscale].* FROM [Tkscale] WHERE [Tkscale].[TicketNo] = @0 ORDER BY [Tkscale].["TicketNo", "UniqueID", "ItemNo"] ASC OFFSET 0 ROWS FETCH NEXT @1 ROWS ONLY', N'@0 nvarchar(max), @1 int', @0 = N'10234770', @1 = 1 which is odd since I didn't ask for the ordering. I'm not sure how to fix this. I have set MyRecord.table_name = 'Tkbatch' and MyRecord.primary_key = :UniqueId. MyRecord.connection.schema_cache.primary_keys("Tkbatch") returns ["TicketNo", "UniqueID", "ItemNo"]. I can't find an issue or in the code where this should be addressed. any ideas?
    I could get around it by setting a default scope with an order but that's kind of a workaround
    Benjamin Fleischer
    @metaskills --^
    I'm just starting out and learning a lot. Is this supported by the latest Active Record?
    John Paul Bamberg
    I'm running ubuntu. The rails 4 app with my config worked on my mac. I'm getting an error:
    "Unable Adaptive Server connection failed (servername.database.secure.windows.net:1433)"
    tiny_tds (2.1.2) lib/tiny_tds/client.rb:60:in 'connect'
    tiny_tds (2.1.2) lib/tiny_tds/client.rb:60:in 'initialize'
    If I look at the username of the opts being passed to connect is has the wrong username. There was an @server automatically appended to it. I don't know if that is what the problem might be?
    Please help. I've been stuck on this for dayyyyssss
    Hello, Wanted to check if there are plans to upgrade openssl to latest version as default i.e 1.1.0f
    Corey Vincent
    Hello I'm trying to connect to a Sql Server that is on a remote windows server, using ruby. I've tried using the gem tiny_tds, but I keep getting a connect server name not founderror. I'm thinking this is just for connecting to a local sql server, and not one that is on a completely different machine. Can anyone point me in the right direction?
    Vincent Smith

    Perhaps I'm missing something, is there a way to define an Identity column that is not a primary key?

    I am working with a legacy database which has some non-PK identity columns. When a performed a schema dump against our development database nothing seems to indicate that these columns are to be auto incremented.

    Oliver Miehe
    Hi, we want to use Ruby 2.6 and tiny_tds is currently only running with 2.5. Do you already know a timeline when we can expect Support for 2.6?
    Thx in advance!
    Eduardo J Moreno M
    I'm working with Windows 10, Ruby 2.6 and already tryed to install tiny_tds with gem install --platform ruby tiny_tds without success. I saw that currently there isn't ruby 2.6 support for this gem. Any workaround so far?
    Rafael Vicente Saura
    hello I have a doubt I need a non relational database for now I am using mongodb and I am happy with it but sql has taken filetables that allows the use of files in the sql Which is better?