プロジェクト

全般

プロフィール

Vote #71841

完了

rake redmine:load_default_data error in 2.0 with SQLServer

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Database_21
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
21
version_id:
60
issue_org_id:
10930
author_id:
1012
assigned_to_id:
6508
comments:
19
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
43
ステータス-->[Closed]

説明

C:\Ruby\Redmine>rake redmine:load_default_data --trace
** Invoke redmine:load_default_data (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute redmine:load_default_data

Select language: ar, bg, bs, ca, cs, da, de, el, en, en-GB, es, et, eu, fa, fi, fr, gl, he, hr, hu, id, it, ja, ko, lt, lv, mk, mn, nl, no, pl, pt, pt-BR, ro, r

u, sk, sl, sq, sr, sr-YU, sv, th, tr, uk, vi, zh, zh-TW [en]

rake aborted!
can't convert ActiveRecord::StatementInvalid into String
C:/Ruby/Redmine/lib/tasks/load_default_data.rake:31:in +'
C:/Ruby/Redmine/lib/tasks/load_default_data.rake:31:in
rescue in block (2 levels) in '
C:/Ruby/Redmine/lib/tasks/load_default_data.rake:25:in block (2 levels) in <top (required)>'
C:/Ruby/193/lib/ruby/1.9.1/rake/task.rb:205:in
call'
C:/Ruby/193/lib/ruby/1.9.1/rake/task.rb:205:in block in execute'
C:/Ruby/193/lib/ruby/1.9.1/rake/task.rb:200:in
each'
C:/Ruby/193/lib/ruby/1.9.1/rake/task.rb:200:in execute'
C:/Ruby/193/lib/ruby/1.9.1/rake/task.rb:158:in
block in invoke_with_call_chain'
C:/Ruby/193/lib/ruby/1.9.1/monitor.rb:211:in mon_synchronize'
C:/Ruby/193/lib/ruby/1.9.1/rake/task.rb:151:in
invoke_with_call_chain'
C:/Ruby/193/lib/ruby/1.9.1/rake/task.rb:144:in invoke'
C:/Ruby/193/lib/ruby/1.9.1/rake/application.rb:116:in
invoke_task'
C:/Ruby/193/lib/ruby/1.9.1/rake/application.rb:94:in block (2 levels) in top_level'
C:/Ruby/193/lib/ruby/1.9.1/rake/application.rb:94:in
each'
C:/Ruby/193/lib/ruby/1.9.1/rake/application.rb:94:in block in top_level'
C:/Ruby/193/lib/ruby/1.9.1/rake/application.rb:133:in
standard_exception_handling'
C:/Ruby/193/lib/ruby/1.9.1/rake/application.rb:88:in top_level'
C:/Ruby/193/lib/ruby/1.9.1/rake/application.rb:66:in
block in run'
C:/Ruby/193/lib/ruby/1.9.1/rake/application.rb:133:in standard_exception_handling'
C:/Ruby/193/lib/ruby/1.9.1/rake/application.rb:63:in
run'
C:/Ruby/193/bin/rake:32:in `

'
Tasks: TOP => redmine:load_default_data


journals

Actually this looks like a problem with https://github.com/rails-sqlserver/activerecord-sqlserver-adapter. I will open a ticket with them.
--------------------------------------------------------------------------------
BTW, SQL Server backend is not supported for the time being.
--------------------------------------------------------------------------------
Yes I am aware. It has been working good up until 2.0 but I think the adapter has a bug in it so I will open a case with them.
--------------------------------------------------------------------------------
Jason Trahan wrote:
> Yes I am aware. It has been working good up until 2.0 but I think the adapter has a bug in it so I will open a case with them.

I'm curious about the amount of work you had to go before having Redmine fully working with SQL server, if you don't mind?
--------------------------------------------------------------------------------
Virtually none. I had to manually change 1 thing in the database due to a bug in the adapter not converting an int to an nvarchar, but for redmine itself i didn't have to make any changes.

However something with the adtapter is generating this sql statement which is invalid because the order by has the same column twice sorting by both directions which is invalid.

EXEC sp_executesql N'SELECT TOP (1) [enumerations].* FROM [enumerations] WHERE (type = ''DocumentCategory'') *ORDER BY enumerations.position ASC, position DESC*'
--------------------------------------------------------------------------------
Should be avoidable by tweaking source:/tags/2.0.0/app/models/enumeration.rb#L21 and source:/tags/2.0.0/app/models/enumeration.rb#L27.
--------------------------------------------------------------------------------
Commenting out those 2 lines does seem to help with the data load. I will put them back in and see how normal operation is.
--------------------------------------------------------------------------------
Actually I'm not even sure that the @act_as_tree@ is useful??

Right now I don't get the purpose of r2947.
--------------------------------------------------------------------------------
Actually that act_as_tree seems to be the culprit. If I comment out that line instead of the default_scope it works.
--------------------------------------------------------------------------------
correction. once I truncated the tables and tried again it still errored out. Weird thing is that the default_scope has existed since 2009 and has worked so I am thinking some other change was made that is causing the adtapter to generate both order bys.
--------------------------------------------------------------------------------
if I remove default_scope then the sql statement comes out to this below which is correct.

EXEC sp_executesql N'SELECT TOP (1) [enumerations].* FROM [enumerations] WHERE (type = ''DocumentCategory'') ORDER BY position DESC'
--------------------------------------------------------------------------------
OK I was able to get the data loaded and I put the default_scope back in. So far it is working like the previous versions so I'm not sure what during the load defaults is causing the issue. I guess I can leave it in your hands.
--------------------------------------------------------------------------------
Opened a ticket here too to see if they say if this is an adapter issue or not.

https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues/203
--------------------------------------------------------------------------------
Based on this comment. https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues/203#issuecomment-5761927

I modified subversion.rb and changed

<pre>
def latest_changesets(path, rev, limit=10)
revisions = scm.revisions(path, rev, nil, :limit => limit)
revisions ? changesets.find_all_by_revision(revisions.collect(&:identifier), :order => "committed_on DESC", :include => :user) : []
end
</pre>

to

<pre>
def latest_changesets(path, rev, limit=10)
revisions = scm.revisions(path, rev, nil, :limit => limit)
revisions ? changesets.find_all_by_revision(revisions.collect(&:identifier), :order => "#{Changeset.table_name}.committed_on DESC", :include => :user) : []
end
</pre>

I imagine this will need to be done in various places to make it more compliant with mssql. I'm still not sure why this became a problem when I upgraded to 2.0.0 and the latest sql adapter because in 1.4.x it was working without any changes.
--------------------------------------------------------------------------------
Etienne Massip wrote:
> I'm curious about the amount of work you had to go before having Redmine fully
> working with SQL server, if you don't mind?

I inherited a Redmine 1.0.4 database from another developer. He said he'd had issues getting dates to work, though that was with ODBC and the description of TinyTDS sounds like it may have solved that. He never got the Gantt view working, but it does now which backs that up.

Aside from this sorting issue, the only other one I've encountered is that any attempt to sort or group by a custom field will fail. Filtering is fine. The problem is that the SQL includes a LIMIT clause which MSSQL doesn't recognise. Maybe that's the driver too? Our workaround is to point Excel at the database to get those queries.

--------------------------------------------------------------------------------
A simple fix to that is to open a ticket with the guy who writes the adapter and ask him to convert the limit statements to top statements. He does other conversions now with the adapter.
--------------------------------------------------------------------------------
OK, I'll get some evidence together tomorrow and open a ticket. Thanks Jason.
--------------------------------------------------------------------------------
This was fixed in r11100 as part of SQLServer support for 2.3.0 (#12713).
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

Admin Redmine さんが約4年前に更新

  • カテゴリDatabase_21 にセット
  • 対象バージョン2.3.0_60 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0