-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(model): Adds missing db.close on model:fild_all
Method call was missing. Discovered due to new tests added. Opening and closing of db will be tested automatically from now on.
- Loading branch information
Showing
2 changed files
with
34 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
-------------------------------------------------------------------------------- | ||
-- model.lua, v0.7: basic model creator, uses db module | ||
-- model.lua, v0.7.1: basic model creator, uses db module | ||
-- This file is a part of Sailor project | ||
-- Copyright (c) 2014 Etiene Dalcol <[email protected]> | ||
-- License: MIT | ||
|
@@ -19,6 +19,7 @@ function model:new(obj) | |
obj = util.deepcopy(obj) | ||
|
||
setmetatable(obj,self) | ||
-- REWRITE | ||
self.__index = function (table, key) | ||
if key ~= "attributes" and key ~= "@name" and key ~= "relations" and key ~= "loaded_relations" and key ~= "db" and not model[key] and key ~= "errors" then | ||
if obj.relations and obj.relations[key] then | ||
|
@@ -254,7 +255,7 @@ function model:find_all(where_string) | |
where_string = '' | ||
end | ||
local res = db.query("select * from "..self.db.table..where_string..";") | ||
|
||
db.close() | ||
if not res then return {} end | ||
|
||
for k,_ in ipairs(res) do | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters