Commit e7df02c
Fix geometry type: perf, nil-limit crash, adapter pollution, and DDL hardening
- Build the RGeo factory, WKB/WKT parsers, and WKB generator once in the
Geometry type's initializer instead of rebuilding them on every cast/
serialize. A GEOS factory was previously allocated per value read; it is
invariant per column. Eager construction (vs. lazy memoization) is also
required because AR freezes Type instances after initialization.
- Guard the nil-limit path: a bare `geometry` column (no type/srid modifier)
has no limit, so `limit[:srid]` raised NoMethodError on read. Add a `srid`
helper defaulting to 0 (PostGIS "unknown SRID").
- type_to_sql: coerce srid with `to_i` so it cannot carry arbitrary text into
the geometry() type modifier.
- Use `merge` instead of `merge!` for NATIVE_DATABASE_TYPES so the parent
PostgreSQLAdapter's type map is not mutated with :geometry.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 5796ece commit e7df02c
3 files changed
Lines changed: 20 additions & 7 deletions
File tree
- lib/active_record/connection_adapters
- postgis
- oid
Lines changed: 18 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
11 | 24 | | |
12 | 25 | | |
13 | 26 | | |
| |||
20 | 33 | | |
21 | 34 | | |
22 | 35 | | |
23 | | - | |
| 36 | + | |
24 | 37 | | |
25 | | - | |
| 38 | + | |
26 | 39 | | |
27 | 40 | | |
28 | 41 | | |
| |||
32 | 45 | | |
33 | 46 | | |
34 | 47 | | |
35 | | - | |
| 48 | + | |
36 | 49 | | |
37 | 50 | | |
38 | 51 | | |
| |||
44 | 57 | | |
45 | 58 | | |
46 | 59 | | |
47 | | - | |
48 | | - | |
| 60 | + | |
| 61 | + | |
49 | 62 | | |
50 | 63 | | |
51 | 64 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
0 commit comments