Commit 9092945a authored by François Perrad's avatar François Perrad

compat with lua-Coat 0.9.0

parent 18d128b6
Revision history for lua-CoatPersistent
0.1.3
0.2.0
+ work with LuaSQL 2.3.0
+ add an alternate implementation for LuaSQLite3 (lsqlite3)
+ compat with lua-Coat 0.9.0
0.1.2 Sat Mar 3 22:30:00 2012
+ work with Lua 5.2.0
......
......@@ -11,5 +11,5 @@ maintainer = "Francois Perrad"
depends = {
"lua ~> 5.1",
"dado >= 1.2.0",
"lua-coat >= 0.8.6",
"lua-coat >= 0.9.0",
}
......@@ -21,7 +21,7 @@ dependencies = {
'luasql-sqlite3 >= 2.2.0',
-- 'lsqlite3 >= 0.7',
'dado >= 1.2.0',
'lua-coat >= 0.8.6',
'lua-coat >= 0.9.0',
'lua-testmore >= 0.2.3',
}
build = {
......
......@@ -17,8 +17,9 @@ local dado = require 'dado.sql'
local error = Coat.error
local argerror = Coat.argerror
local checktype = Coat.checktype
local _class = Coat._class
local class = Coat.class
local has = Coat.has
local setfenv = Coat.setfenv
local type = Coat.type
_ENV = nil
......@@ -307,7 +308,7 @@ function _G.persistent (modname, options)
checktype('persistent', 2, options, 'table')
local primary_key = options.primary_key or 'id'
local table_name = options.table_name or modname:gsub('%.', '_')
local M = _class(modname)
local M = class(modname)
M._PRIMARY_KEY = primary_key
M._TABLE_NAME = table_name:lower()
M._ATTR_P = { primary_key }
......@@ -322,11 +323,12 @@ function _G.persistent (modname, options)
M.has_one = setmetatable({}, { __newindex = function (t, k, v) has_one(M, k, v) end })
M.has_many = setmetatable({}, { __newindex = function (t, k, v) has_many(M, k, v) end })
has(M, primary_key, { is = 'rw', isa = 'number' })
setfenv(2, M)
end
_M._VERSION = "0.1.2"
_M._DESCRIPTION = "lua-CoatPersistent : an ORM for lua-Coat"
_M._COPYRIGHT = "Copyright (c) 2010-2012 Francois Perrad"
_M._COPYRIGHT = "Copyright (c) 2010-2013 Francois Perrad"
return _M
--
-- This library is licensed under the terms of the MIT/X11 license,
......
......@@ -18,8 +18,9 @@ local sqlite3 = require 'lsqlite3'
local error = Coat.error
local argerror = Coat.argerror
local checktype = Coat.checktype
local _class = Coat._class
local class = Coat.class
local has = Coat.has
local setfenv = Coat.setfenv
local type = Coat.type
_ENV = nil
......@@ -295,7 +296,7 @@ function _G.persistent (modname, options)
checktype('persistent', 2, options, 'table')
local primary_key = options.primary_key or 'id'
local table_name = options.table_name or modname:gsub('%.', '_')
local M = _class(modname)
local M = class(modname)
M._PRIMARY_KEY = primary_key
M._TABLE_NAME = table_name:lower()
M._ATTR_P = { primary_key }
......@@ -310,13 +311,14 @@ function _G.persistent (modname, options)
M.has_one = setmetatable({}, { __newindex = function (t, k, v) has_one(M, k, v) end })
M.has_many = setmetatable({}, { __newindex = function (t, k, v) has_many(M, k, v) end })
has(M, primary_key, { is = 'rw', isa = 'number' })
setfenv(2, M)
end
_G.package.loaded['Coat.Persistent'] = _M
_M._VERSION = "0.1.2"
_M._DESCRIPTION = "lua-CoatPersistent : an ORM for lua-Coat"
_M._COPYRIGHT = "Copyright (c) 2010-2012 Francois Perrad"
_M._COPYRIGHT = "Copyright (c) 2010-2013 Francois Perrad"
return _M
--
-- This library is licensed under the terms of the MIT/X11 license,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment