sql-athame 0.4.0a11__py3-none-any.whl → 0.4.0a12__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_athame/dataclasses.py CHANGED
@@ -230,8 +230,21 @@ class ModelBase:
230
230
 
231
231
  @classmethod
232
232
  def field_names_sql(
233
- cls, *, prefix: Optional[str] = None, exclude: FieldNamesSet = ()
233
+ cls,
234
+ *,
235
+ prefix: Optional[str] = None,
236
+ exclude: FieldNamesSet = (),
237
+ as_prepended: Optional[str] = None,
234
238
  ) -> list[Fragment]:
239
+ if as_prepended:
240
+ return [
241
+ sql(
242
+ "{} AS {}",
243
+ sql.identifier(f, prefix=prefix),
244
+ sql.identifier(f"{as_prepended}{f}"),
245
+ )
246
+ for f in cls.field_names(exclude=exclude)
247
+ ]
235
248
  return [
236
249
  sql.identifier(f, prefix=prefix) for f in cls.field_names(exclude=exclude)
237
250
  ]
@@ -300,6 +313,16 @@ class ModelBase:
300
313
  cls.from_mapping = from_mapping_fn # type: ignore
301
314
  return from_mapping_fn(mapping)
302
315
 
316
+ @classmethod
317
+ def from_prepended_mapping(
318
+ cls: type[T], mapping: Mapping[str, Any], prepend: str
319
+ ) -> T:
320
+ filtered_dict: dict[str, Any] = {}
321
+ for k, v in mapping.items():
322
+ if k.startswith(prepend):
323
+ filtered_dict[k[len(prepend) :]] = v
324
+ return cls.from_mapping(filtered_dict)
325
+
303
326
  @classmethod
304
327
  def ensure_model(cls: type[T], row: Union[T, Mapping[str, Any]]) -> T:
305
328
  if isinstance(row, cls):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sql-athame
3
- Version: 0.4.0a11
3
+ Version: 0.4.0a12
4
4
  Summary: Python tool for slicing and dicing SQL
5
5
  Project-URL: homepage, https://github.com/bdowning/sql-athame
6
6
  Project-URL: repository, https://github.com/bdowning/sql-athame
@@ -398,4 +398,4 @@ TODO, for now read the [source](sql_athame/dataclasses.py).
398
398
  MIT.
399
399
 
400
400
  ---
401
- Copyright (c) 2019, 2020 Brian Downing
401
+ Copyright (c) 2019–2025 Brian Downing
@@ -1,11 +1,11 @@
1
1
  sql_athame/__init__.py,sha256=0GA9-xfnZ_gw7Vysx6t4iInQ2kGXos1EYwBI6Eb7auU,100
2
2
  sql_athame/base.py,sha256=FR7EmC0VkX1VRgvAutSEfYSWhlEYpoqS1Kqxp1jHp6Y,10293
3
- sql_athame/dataclasses.py,sha256=0XjLXpSBgdtWqJkTdaluLs8_RXPlfJp5ERKGOe-bXBM,27442
3
+ sql_athame/dataclasses.py,sha256=rqobdKMHEohVJknEj6Vv2UzihgOttaROEhnwuO6G4LQ,28155
4
4
  sql_athame/escape.py,sha256=kK101xXeFitlvuG-L_hvhdpgGJCtmRTprsn1yEfZKws,758
5
5
  sql_athame/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  sql_athame/sqlalchemy.py,sha256=aWopfPh3j71XwKmcN_VcHRNlhscI0Sckd4AiyGf8Tpw,1293
7
7
  sql_athame/types.py,sha256=FQ06l9Uc-vo57UrAarvnukILdV2gN1IaYUnHJ_bNYic,475
8
- sql_athame-0.4.0a11.dist-info/METADATA,sha256=DXasc1ZenA7rqqTPu0G0Y1dfFEGmzngZGhAnUxGJAcs,12570
9
- sql_athame-0.4.0a11.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
10
- sql_athame-0.4.0a11.dist-info/licenses/LICENSE,sha256=xqV29vPFqITcKifYrGPgVIBjq4fdmLSwY3gRUtDKafg,1076
11
- sql_athame-0.4.0a11.dist-info/RECORD,,
8
+ sql_athame-0.4.0a12.dist-info/METADATA,sha256=kBYRXE0MC2W8jGbX3NqZpDvOeBKxqnu-vlAKCx5ka5o,12571
9
+ sql_athame-0.4.0a12.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
10
+ sql_athame-0.4.0a12.dist-info/licenses/LICENSE,sha256=kPtZhuBL-A3tMrge4oz5bm_Di2M8KcA-sJY7abTEfZ4,1075
11
+ sql_athame-0.4.0a12.dist-info/RECORD,,
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2019, 2020 Brian Downing
3
+ Copyright (c) 2019-2025 Brian Downing
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal