Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relations & grouping #6

Merged
merged 18 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 132 additions & 10 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,149 @@
===============================================================================================================================================
**`1.0.2`**
===============================================================================================================================================
===
Dataloom **`2.0.0`**
===

### Release Notes - `dataloom`

We have release the new `dataloom` Version `2.0.0` (`2024-02-12`)

##### Features

- Renaming the class `Dataloom` to `Loom`.
```py
from dataloom import Loom
```
- Eager data fetching in relationships

- Now you can fetch your child relationship together in your query

```py
user = mysql_loom.find_one(
instance=User,
filters=[Filter(column="id", value=userId)],
include=[Include(model=Profile, select=["id", "avatar"], has="one")],
)
print(user)
```

- You can apply limits, offsets, filters and orders to your child associations during queries

```py
post = mysql_loom.find_one(
instance=Post,
filters=[Filter(column="userId", value=userId)],
select=["title", "id"],
include=[
Include(
model=User,
select=["id", "username"],
has="one",
include=[Include(model=Profile, select=["avatar", "id"], has="one")],
),
Include(
model=Category,
select=["id", "type"],
has="many",
order=[Order(column="id", order="DESC")],
limit=2,
),
],
)
```

- Now `return_dict` has bee removed as an option in `dataloom` in the query functions like `find_by_pk`, `find_one`, `find_many` and `find_all` now works starting from this version. If you enjoy working with python objects you have to maneuver them manually using experimental features.

```py
from dataloom.decorators import initialize

@initialize(repr=True, to_dict=True, init=True, repr_identifier="id")
class Profile(Model):
__tablename__: Optional[TableColumn] = TableColumn(name="profiles")
id = PrimaryKeyColumn(type="int", auto_increment=True)
avatar = Column(type="text", nullable=False)
userId = ForeignKeyColumn(
User,
maps_to="1-1",
type="int",
required=True,
onDelete="CASCADE",
onUpdate="CASCADE",
)

# now you can do this

profile = mysql_loom.find_many(
instance=Profile,
)
print([Profile(**p) for p in profile]) # ? = [<Profile:id=1>]
print([Profile(**p) for p in profile][0].id) # ? = 1
```

- These are `experimental` decorators they are little bit slow and they work perfect in a single instance, you can not nest relationships on them.
- You can use them if you know how your data is structured and also if you know how to manipulate dictionaries

- Deprecated ~~`join_next_filter_with`~~ to the use of `join_next_with`
- Values that was required as `list` e.g, `select`, `include` etc can now be passed as a single value.

- **Before**

```py
res = mysql_loom.find_by_pk(Profile, pk=profileId, select={"id", "avatar"}) # invalid
res = mysql_loom.find_by_pk(Profile, pk=profileId, select=("id", "avatar")) # invalid
res = mysql_loom.find_by_pk(Profile, pk=profileId, select="id") # invalid
res = mysql_loom.find_by_pk(Profile, pk=profileId, select=["id"]) # valid

```

- **Now**

```py
res = mysql_loom.find_by_pk(Profile, pk=profileId, select={"id", "avatar"}) # valid
res = mysql_loom.find_by_pk(Profile, pk=profileId, select=("id", "avatar")) # valid
res = mysql_loom.find_by_pk(Profile, pk=profileId, select="id") # valid
res = mysql_loom.find_by_pk(Profile, pk=profileId, select=["id"]) # valid

```

- Updated the documentation.
- Grouping data in queries will also be part of this release, using the class `Group` and `Having`.

```py
posts = pg_loom.find_many(
Post,
select="id",
filters=Filter(column="id", operator="gt", value=1),
group=Group(
column="id",
function="MAX",
having=Having(column="id", operator="in", value=(2, 3, 4)),
return_aggregation_column=True,
),
)
```

=====
Dataloom **`1.0.2`**
=====

We have release the new `dataloom` Version `1.0.2` (`2024-02-12`)

### Changes

We have updated the documentation so that it can look more colorful.

===============================================================================================================================================
**`1.0.1`**
===============================================================================================================================================

=====
Dataloom **`1.0.1`**
=====
Change logs for the `dataloom` Version `1.0.1` (`2024-02-12`)

### New Features

- **Docstring**: Now the functions and classes have a beautiful docstring that helps ypu with some examples and references in the editor.
- **SQL Loggers**: The SQL Loggers can now log `timestamps` not the log index especially for the `console` logger.

===============================================================================================================================================
**`1.0.0`**
===============================================================================================================================================
=====
Dataloom **`1.0.0`**
=====

### Release Notes - `dataloom`

Expand Down
Loading