Skip to content

Commit c2d05ae

Browse files
committed
Add documentation
1 parent b8ae9c9 commit c2d05ae

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,19 @@ The removal of duplicates happens during the SQL query.
186186

187187
Because of this implementation, if you pass `on_duplicate` to `upsert_all`, make sure to assign your value to `target.[column_name]` (e.g. `target.status = GREATEST(target.status, 1)`). To access the values that you want to upsert, use `source.[column_name]`.
188188

189+
#### Computed Columns
190+
191+
The adapter supports computed columns. They can either be virtual `stored: false` (default) and persisted `stored: true`. You can create a computed column in a migration like so:
192+
193+
```ruby
194+
create_table :users do |t|
195+
t.string :name
196+
t.virtual :lower_name, as: "LOWER(name)", stored: false
197+
t.virtual :upper_name, as: "UPPER(name)", stored: true
198+
t.virtual :name_length, as: "LEN(name)"
199+
end
200+
```
201+
189202
## New Rails Applications
190203

191204
When creating a new Rails application you need to perform the following steps to connect a Rails application to a

lib/active_record/connection_adapters/sqlserver/schema_statements.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def columns(table_name)
9494
end
9595
end
9696

97-
def new_column_from_field(table_name, field, definitions)
97+
def new_column_from_field(_table_name, field, _definitions)
9898
sqlserver_options = field.slice(:ordinal_position, :is_primary, :is_identity, :table_name)
9999
sql_type_metadata = fetch_type_metadata(field[:type], sqlserver_options)
100100
generated_type = extract_generated_type(field)

0 commit comments

Comments
 (0)