OSDN Git Service

add support functions to db accessor
[amulettoolsmh4/main.git] / model / amuletskillsholder.py
index b334fd3..355f5dc 100644 (file)
@@ -33,3 +33,19 @@ class AmuletSkillsHolder(object):
                 return u" where " + u" and ".join(valid_eqls)
         else:
             return ""
+
+    def get_where_in_sql(self, remove_where=False):
+        u""" SQLのWhere文に変換する(IN結合) """
+        if len(self.skill_id_list) >= 1:
+            uni_list = [u"{0}".format(x) for x in self.skill_id_list if x is not None]
+            sql = u" {col} IN({in_phrase})".format(
+                    col=db_supports.MIN_MAX_COL_SKILL_ID,
+                    in_phrase=u",".join(uni_list))
+
+            if remove_where:
+                return sql
+            else:
+                return u" where" + sql
+        else:
+            return ""
+