sqlserver_adapter.rb in active record seems be screwin up with add_limit_offset
it’s not showin SQL Server ANY love ….
try this one, i’ve commented out some bits that didnt seem to need to be there (for me anyway… if my progs change may be I’ll need to put em back in)
p. and i’ve added the lineparts[0]=""
this strips out the table name from the ‘nested selects’ that are used to fake the offset and limit there’s gotta be a better way than this
def add_limit_offset!(sql, options)
if options[:limit] and options[:offset]
total_rows = @connection.select_all("SELECT count(*) as TotalRows from (#{sql.gsub(/\bSELECT(\s+DISTINCT)?\b/i, "SELECT#{$1} TOP 1000000000")}) tally")[0][:TotalRows].to_i
if (options[:limit] + options[:offset]) >= total_rows
options[:limit] = (total_rows - options[:offset] >= 0) ? (total_rows - options[:offset]) : 0
end
sql.sub!(/^\s*SELECT(\s+DISTINCT)?/i, "SELECT * FROM (SELECT TOP #{options[:limit]} * FROM (SELECT#{$1} TOP #{options[:limit] + options[:offset]} ")
sql << ") AS tmp1"
if options[:order]
options[:order] = options[:order].split(',').map do |field|
parts = field.split(".")
tc = parts[0]
# if sql =~ /\.\[/ and tc =~ /\./ # if column quoting used in query
# tc.gsub!(/\./, '\\.\\[')
# tc << '\\]'
# end
# if sql =~ /#{tc} AS (t\d_r\d\d?)/
# parts[0] = $1
# elsif parts[0] =~ /\w+\.(\w+)/
# parts[0] = $1
# end
parts[0]=""
parts.join(' ')
end.join(', ')
sql << " ORDER BY #{change_order_direction(options[:order])}) AS tmp2 ORDER BY #{options[:order]}"
else
sql << " ) AS tmp2"
end
elsif sql !~ /^\s*SELECT (@@|COUNT\()/i
sql.sub!(/^\s*SELECT(\s+DISTINCT)?/i) do
"SELECT#{$1} TOP #{options[:limit]}"
end unless options[:limit].nil?
end
end
p. Still getting to grips with Textile … oh well
p. Went to http://josephlindsay.com/archives/2005/05/27/paging-results-in-ms-sql-server/
found this snippet by Adam of http://www.esendex.com
seems like a way forward I’ll try to find time to look at … hell if it works out i might even let you know
SELECT fields FROM ( SELECT TOP x * FROM ( SELECT TOP y id_field, sort_field FROM table WHERE conditions ORDER sort_field ASC) as foo ORDER by sort_field DESC) as bar INNER JOIN table ON bar.id_field = table.id_field ORDER by sort_field ASC
http://www.igvita.com/2008/02/11/nginx-and-memcached-a-400-boost/
I’m trying to put MONO on my server for hosting some asp.net stuff. Can i get it to work with NGINX …. not much NO
So that means turning to another server it’s apache, lighty or cherokee….. apache is BIG… limited space says look at other options first….lightt step forward…... no… step back …you’re mode rewrite sucks ..back in ya box !!!!.... ok it’s prob gonna be cherokee’s finest moment this…..i’ll let you know
Hats off to Weifen Luo, I’ve used this suite a couple of times and it ROCKS !!!
give this a whirl http://www.codeproject.com/sqlrs/PassingArraysSQLParameter.asp
Public NotInheritable Class ReliabilityOptimizedControl
'Defines a list for storing the delegates
Private EventHandlerList As New ArrayList
'Defines the Click event using the custom event syntax.
'The RaiseEvent always invokes the delegates asynchronously
Public Custom Event Click As EventHandler
AddHandler(ByVal value As EventHandler)
EventHandlerList.Add(value)
End AddHandler
RemoveHandler(ByVal value As EventHandler)
EventHandlerList.Remove(value)
End RemoveHandler
RaiseEvent(ByVal sender As Object, ByVal e As EventArgs)
For Each handler As EventHandler In EventHandlerList
If handler IsNot Nothing Then
handler.BeginInvoke(sender, e, Nothing, Nothing)
End If
Next
End RaiseEvent
End Event
End Class
Notice how the event is declared as Public Custom Event… this allows us to set our own delegate ‘store’ for handlers The closest that vb.net get to Multipl inheritance is interfaces….but does it HAVE to end there …?
Serializing objects in VB has a few ….gotchas…