Last active
December 17, 2015 04:59
-
-
Save zerokarmaleft/5554349 to your computer and use it in GitHub Desktop.
Sequel::DatabaseError: TinyTds::Error: Incorrect syntax near the keyword 'AS'.
from /home/echo/.rvm/gems/ruby-2.0.0-p0/gems/sequel-3.47.0/lib/sequel/adapters/tinytds.rb:234:in `fields'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT ([SUBJECTID], [NUM_BDI_TIMEPOINTS]) | |
| FROM [SUBJECTIDENTIFIERS] | |
| INNER JOIN (SELECT [SUBJECTID], count([BDI_TP]) AS [NUM_BDI_TIMEPOINTS] | |
| FROM [BDIS_OUTPUT] | |
| WHERE ((([BDI_TP] COLLATE Latin1_General_CS_AS) | |
| LIKE | |
| (N'Y%' COLLATE Latin1_General_CS_AS) ESCAPE N'\\')) | |
| GROUP BY [SUBJECTID]) AS [T1] | |
| ON ([T1].[SUBJECTID] = [SUBJECTIDENTIFIERS].[SUBJECTID]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT ([SUBJECTIDENTIFIERS].[SUBJECTID], [NUM_BDI_TIMEPOINTS]) | |
| FROM [SUBJECTIDENTIFIERS] | |
| INNER JOIN (SELECT [SUBJECTID], count([BDI_TP]) AS [NUM_BDI_TIMEPOINTS] | |
| FROM [BDIS_OUTPUT] | |
| WHERE ([BDI_TP] LIKE 'Y%') | |
| GROUP BY [SUBJECTID]) AS [T1] | |
| ON ([T1].[SUBJECTID] = [SUBJECTIDENTIFIERS].[SUBJECTID]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'sequel' | |
| Sequel::Model.db = Sequel.tinytds(host: "secretstuff", | |
| database: "secretstuff", | |
| username: "secretstuff", | |
| password: "secretstuff") | |
| class Subject < Sequel::Model(:subjectidentifiers) | |
| set_primary_key :subjectid | |
| one_to_many :bdimeasures, :key => :subjectid | |
| def self.candidates() | |
| bdi_counts = BDIMeasure. | |
| select{[:subjectid, count(:bdi_tp).as(:num_bdi_timepoints)]}. | |
| grep(:bdi_tp, 'Y%'). | |
| group_by(:subjectid) | |
| subjects = Subject. | |
| select([:subjectid, :num_bdi_timepoints]). | |
| join(bdi_counts, :subjectid => :subjectid). | |
| filter { num_bdi_timepoints >= 3 } | |
| end | |
| end | |
| class BDIMeasure < Sequel::Model(:bdis_output) | |
| set_primary_key [:subjectid, :bdi_tp] | |
| many_to_one :subject, :key => :subjectid | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment