Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
annotate
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
annotate
Commits
8bfeeb25
Commit
8bfeeb25
authored
Nov 09, 2012
by
Gary S. Weaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding support for composite_primary_keys
parent
4a96f3a1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletion
+20
-1
annotate_models.rb
lib/annotate/annotate_models.rb
+1
-1
annotate_models_spec.rb
spec/annotate/annotate_models_spec.rb
+19
-0
No files found.
lib/annotate/annotate_models.rb
View file @
8bfeeb25
...
@@ -113,7 +113,7 @@ module AnnotateModels
...
@@ -113,7 +113,7 @@ module AnnotateModels
attrs
=
[]
attrs
=
[]
attrs
<<
"default(
#{
quote
(
col
.
default
)
}
)"
unless
col
.
default
.
nil?
attrs
<<
"default(
#{
quote
(
col
.
default
)
}
)"
unless
col
.
default
.
nil?
attrs
<<
"not null"
unless
col
.
null
attrs
<<
"not null"
unless
col
.
null
attrs
<<
"primary key"
if
klass
.
primary_key
&&
col
.
name
.
to_sym
==
klass
.
primary_key
.
to_sym
attrs
<<
"primary key"
if
klass
.
primary_key
&&
(
klass
.
primary_key
.
is_a?
(
Array
)
?
klass
.
primary_key
.
collect
{
|
c
|
c
.
to_sym
}.
include?
(
col
.
name
.
to_sym
)
:
col
.
name
.
to_sym
==
klass
.
primary_key
.
to_sym
)
col_type
=
(
col
.
type
||
col
.
sql_type
).
to_s
col_type
=
(
col
.
type
||
col
.
sql_type
).
to_s
if
col_type
==
"decimal"
if
col_type
==
"decimal"
...
...
spec/annotate/annotate_models_spec.rb
View file @
8bfeeb25
...
@@ -73,6 +73,25 @@ EOS
...
@@ -73,6 +73,25 @@ EOS
EOS
EOS
end
end
it
"should get schema info even if the primary key is array, if using composite_primary_keys"
do
klass
=
mock_class
(
:users
,
nil
,
[
[
mock_column
(
:a_id
,
:integer
),
mock_column
(
:b_id
,
:integer
)],
mock_column
(
:name
,
:string
,
:limit
=>
50
)
])
AnnotateModels
.
get_schema_info
(
klass
,
"Schema Info"
).
should
eql
(
<<-
EOS
)
# Schema Info
#
# Table name: users
#
# a_id :integer not null
# b_id :integer not null
# name :string(50) not null
#
EOS
end
it
"should get schema info as RDoc"
do
it
"should get schema info as RDoc"
do
klass
=
mock_class
(
:users
,
:id
,
[
klass
=
mock_class
(
:users
,
:id
,
[
mock_column
(
:id
,
:integer
),
mock_column
(
:id
,
:integer
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment