Compare projects

Project comparisons allow you to view any selection of projects side by side just like they're shown on regular categories or in search results. You can try out an example or start yourself by adding a library to the comparison via the input below. You can also easily share your current comparison with others by sending the URL of the current page.

netshade-sql_valued_columns
0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
= sql_valued_columns SqlValuedColumns is an ActiveRecord plugin that will let you have specific SQL statements executed on INSERT / UPDATE. It will call the SQL function you provide, passing the arguments specified in the call to sql_column. See the documentation for SqlValuedColumns::ClassMethods#sql_column for more information regarding usage, including passing Strings and Proc objects as arguments to your SQL function. Example: You have a model with two columns, one named "another_column" and the other named "size_of_another_column". Whenever you insert data into "another_column", you want to have size_of_another_column have the result of the SQL function LENGTH inserted into it. class MyModel < ActiveRecord::Base sql_column :size_of_another_column, "LENGTH", :another_column end Example 2: You have a model with three columns, position, latitude and longitude. Latitude and longitude are values expressed as angles, and position is a special datatype for your database that represents the X/Y/Z projection of that particular latitude and longitude (example: http://www.postgresql.org/docs/8.3/static/earthdistance.html ) When you insert data with latitude and longitude, you want to automatically call a function in your database to transform the latitude and longitude into the appropriate represenation. class MyModel < ActiveRecord::Base sql_column :position, "ll_to_earth", :latitude, :longitude end Example 3: You are an insane criminal who has somehow learned SQL. You would like to make anyone who runs your code to suffer database punishing queries and odd security and data formatting issues that will make them rue the day they ever learned of computers. class MyModel < ActiveRecord::Base sql_column :a_column, "(SELECT count(id) FROM large_list_of_things)", :raw => true sql_column :another_column, '(SELECT count(other_id) FROM other_large_list_of_things WHERE some_column = \'#{some_model_method}\')', :raw => true end == Notes No tests yet, am lazy. == Copyright Copyright (c) 2009 Chris Zelenak. See LICENSE for details.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024