lib/d3/database.rb in depot3-3.0.9 vs lib/d3/database.rb in depot3-3.0.11
- old
+ new
@@ -40,11 +40,11 @@
# the minimum JSS schema version allower
MIN_SCHEMA_VERSION = "9.4"
# the minimum JSS schema version allower
- MAX_SCHEMA_VERSION = "9.82"
+ MAX_SCHEMA_VERSION = "9.93"
### these Proc objects allow us to encapsulate and pass around various
### blocks of code more easily for converting data between their mysql
### representation and the Ruby classses we use internally.
@@ -57,10 +57,14 @@
### Integers come from the database as strings, but empty ones should be nil, not zero, as #to_i would do
STRING_TO_INT = Proc.new{|v| (v.nil? or v.to_s.empty?) ? nil : v.to_i}
### Some values are stored as comma-separated strings, but used as Arrays
COMMA_STRING_TO_ARRAY = Proc.new{|v| JSS.to_s_and_a(v)[:arrayform] }
+
+ ### Some values are stored as comma-separated strings, but used as Arrays of Pathnames
+ COMMA_STRING_TO_ARRAY_OF_PATHNAMES = Proc.new{|v| JSS.to_s_and_a(v)[:arrayform].map{|p| Pathname.new(p)} }
+ ARRAY_OF_PATHNAMES_TO_COMMA_STRING = Proc.new{|v| v.join(", ")}
### Some values are used as Arrays but stored as comma-separated strings
ARRAY_TO_COMMA_STRING = Proc.new{|v| JSS.to_s_and_a(v)[:stringform] }
### Some values are stored in the DB as YAML dumps
@@ -323,16 +327,16 @@
:index => nil,
:to_sql => nil,
:to_ruby => STRING_TO_INT
},
- :expiration_path => {
+ :expiration_paths => {
:field_name => "expiration_app_path",
:sql_type => 'varchar(300)',
:index => nil,
- :to_sql => PATHNAME_TO_STRING,
- :to_ruby => STRING_TO_PATHNAME
+ :to_sql => ARRAY_OF_PATHNAMES_TO_COMMA_STRING,
+ :to_ruby => COMMA_STRING_TO_ARRAY_OF_PATHNAMES
}
},
:other_indexes => [
"UNIQUE KEY `edition` (`basename`,`version`,`revision`)"
@@ -402,10 +406,11 @@
### Raise an exception if JSS schema is to old or too new
def self.check_schema_version
raw = JSS::DB_CNX.db.query("SELECT version FROM #{SCHEMA_TABLE}").fetch[0]
- current = JSS.parse_jss_version(raw)[:version]
+ simmered = raw.split('.')[0..1].join('.')
+ current = JSS.parse_jss_version(simmered)[:version]
min = JSS.parse_jss_version(MIN_SCHEMA_VERSION)[:version]
max = JSS.parse_jss_version(MAX_SCHEMA_VERSION)[:version]
raise JSS::InvalidConnectionError, "Invalid JSS database schema version: #{raw}, min: #{MIN_SCHEMA_VERSION}, max: #{MAX_SCHEMA_VERSION}" if current < min or current > max
return true
end