anlek / mongify

Mongify allows you to map your data from a sql database and into a mongodb document database.
http://github.com/anlek/mongify
MIT License
317 stars 82 forks source link

Translate sqlserver Multiple Schema #122

Closed kamrankhatti closed 7 years ago

kamrankhatti commented 7 years ago

I have different schema in sqlserver database when I run Mongify translation command it only translates default pdo schema tables and skip columns of other schema table. When I process it, it through this error:

/home/[pcname]/.rvm/gems/ruby-2.1.5/gems/activerecord-sqlserver-adapter-4.2.6/lib/active_record/connection_adapters/sqlserver/database_statements.rb:352:ineach': TinyTds::Error: Invalid object name 'userstest'.: EXEC sp_executesql N'SELECT COUNT(*) FROM userstest' (ActiveRecord::StatementInvalid) from /home/[pcname]/.rvm/gems/ruby-2.1.5/gems/activerecord-sqlserver-adapter-4.2.6/lib/active_record/connection_adapters/sqlserver/database_statements.rb:352:in handle_to_names_and_values_dblib' from /home/[pcname]/.rvm/gems/ruby-2.1.5/gems/activerecord-sqlserver-adapter-4.2.6/lib/active_record/connection_adapters/sqlserver/database_statements.rb:341:inhandle_to_names_and_values' from /home/[pcname]/.rvm/gems/ruby-2.1.5/gems/activerecord-sqlserver-adapter-4.2.6/lib/active_record/connection_adapters/sqlserver/database_statements.rb:316:in _raw_select' from /home/[pcname]/.rvm/gems/ruby-2.1.5/gems/activerecord-sqlserver-adapter-4.2.6/lib/active_record/connection_adapters/sqlserver/database_statements.rb:311:inblock in raw_select'`

is it possible to use different schema tables in Mongify?

srizviOfficial commented 7 years ago

I have similar problem what I able to figure out. basically mongify queries without prefix (schema name) so all queries will execute successfully which are against your default schema set against your user in database, but if you try to query in other schema than syntax not supported (SQL SERVER database with multiple schema) - I am looking forward for answer

anlek commented 7 years ago

Hey Guys, sorry but not sure I can help here. I have no idea about SQL Server and the different schemas. My only recommendation is to see how Ruby on Rails works with SQL Server and the different schemas. Mongify uses ActiveRecord from Rails to make things happen.

srizviOfficial commented 7 years ago

we are handling above issue via Synonyms in SQL Server like below

create synonym EmailTemplate for services.EmailTemplate

Above command in SQL Server create transparent link. Using that you can query database with & without prefixing schema name like below

select from services.EmailTemplate select from EmailTemplate

Mongify querying database without prefix so it's works now with the help of Synonyms.

kamrankhatti commented 7 years ago

Great! this works for me.