sql-blocks 1.25.2__py3-none-any.whl → 1.25.13__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
sql_blocks/sql_blocks.py CHANGED
@@ -151,52 +151,47 @@ class NamedField:
151
151
 
152
152
 
153
153
  class Function:
154
- instance: dict = {}
155
-
156
154
  def __init__(self, *params: list):
157
- func_name = self.__class__.__name__
158
- Function.instance[func_name] = self
155
+ # --- Replace class methods by instance methods: ------
156
+ self.add = self.__add
157
+ self.format = self.__format
158
+ # -----------------------------------------------------
159
159
  self.params = [str(p) for p in params]
160
- self.class_type = Field
160
+ self.field_class = Field
161
161
  self.pattern = '{}({})'
162
162
  self.extra = {}
163
163
 
164
164
  def As(self, field_alias: str, modifiers=None):
165
165
  if modifiers:
166
166
  self.extra[field_alias] = TO_LIST(modifiers)
167
- self.class_type = NamedField(field_alias)
167
+ self.field_class = NamedField(field_alias)
168
168
  return self
169
169
 
170
- @classmethod
171
- def format(cls, name: str, main: SQLObject) -> str:
172
- obj = cls.get_instance()
173
- if name in '*_' and obj.params:
174
- params = obj.params
170
+ def __format(self, name: str, main: SQLObject) -> str:
171
+ if name in '*_' and self.params:
172
+ params = self.params
175
173
  else:
176
174
  params = [
177
175
  Field.format(name, main)
178
- ] + obj.params
179
- return obj.pattern.format(
180
- cls.__name__,
176
+ ] + self.params
177
+ return self.pattern.format(
178
+ self.__class__.__name__,
181
179
  ', '.join(params)
182
180
  )
183
181
 
182
+ @classmethod
183
+ def format(cls, name: str, main: SQLObject):
184
+ return cls().__format(name, main)
185
+
184
186
  def __add(self, name: str, main: SQLObject):
185
187
  name = self.format(name, main)
186
- self.class_type.add(name, main)
188
+ self.field_class.add(name, main)
187
189
  if self.extra:
188
190
  main.__call__(**self.extra)
189
191
 
190
- @classmethod
191
- def get_instance(cls):
192
- obj = Function.instance.get(cls.__name__)
193
- if not obj:
194
- obj = cls()
195
- return obj
196
-
197
192
  @classmethod
198
193
  def add(cls, name: str, main: SQLObject):
199
- cls.get_instance().__add(name, main)
194
+ cls().__add(name, main)
200
195
 
201
196
 
202
197
  # ---- String Functions: ---------------------------------
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sql_blocks
3
- Version: 1.25.2
3
+ Version: 1.25.13
4
4
  Summary: Allows you to create objects for parts of SQL query commands. Also to combine these objects by joining them, adding or removing parts...
5
5
  Home-page: https://github.com/julio-cascalles/sql_blocks
6
6
  Author: Júlio Cascalles
@@ -0,0 +1,7 @@
1
+ sql_blocks/__init__.py,sha256=5ItzGCyqqa6kwY8wvF9kapyHsAiWJ7KEXCcC-OtdXKg,37
2
+ sql_blocks/sql_blocks.py,sha256=P5yp0Ug4PD56xklmQOtpNLKm9hfhHBNb8TDkOneNAHw,45783
3
+ sql_blocks-1.25.13.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
4
+ sql_blocks-1.25.13.dist-info/METADATA,sha256=tahTyaVcsa4ROoxQSMK41W6m20bVlDs6_kh9b9mkgoc,13424
5
+ sql_blocks-1.25.13.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
6
+ sql_blocks-1.25.13.dist-info/top_level.txt,sha256=57AbUvUjYNy4m1EqDaU3WHeP-uyIAfV0n8GAUp1a1YQ,11
7
+ sql_blocks-1.25.13.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- sql_blocks/__init__.py,sha256=5ItzGCyqqa6kwY8wvF9kapyHsAiWJ7KEXCcC-OtdXKg,37
2
- sql_blocks/sql_blocks.py,sha256=R2xZsaKRd600rsZf0lzyXITALpZ3ZXBmwOADNpX1qUA,45798
3
- sql_blocks-1.25.2.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
4
- sql_blocks-1.25.2.dist-info/METADATA,sha256=NKLAHw43avYevBxxWhKBts8tOB2AaKETMp08dCoSAzQ,13423
5
- sql_blocks-1.25.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
6
- sql_blocks-1.25.2.dist-info/top_level.txt,sha256=57AbUvUjYNy4m1EqDaU3WHeP-uyIAfV0n8GAUp1a1YQ,11
7
- sql_blocks-1.25.2.dist-info/RECORD,,