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

DOC Document ORM changes for CMS 5.2 #351

Merged

Conversation

GuySartorelli
Copy link
Member

@GuySartorelli GuySartorelli commented Sep 25, 2023

This PR includes

  • Docs for UNION
  • Docs for WITH
  • Docs for DataQuery::setAllowCollidingFieldStatements() (in changelog only, but feel free to point out a good place for it if you think it deserves its own entry in the main docs somewhere)
  • Update docs that refer to joins to include RIGHT JOIN
  • Changelog entry

Note that the documentation here intentionally doesn't cover every scenario - the 08_SQL_Select.md file already says that there's a lot in here and that people should check the PHPDoc for full usage details.

Issue

Comment on lines -20 to +94
### silverstripe/framework
### silverstripe/framework {#api-silverstripe-framework}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gives a unique anchor ID for this heading to distinguish it from the silverstripe/framework heading that will be automatically generated in the actual changelog below this.
Not strictly necessary as part of this PR but it's a tiny change so I probably wouldn't bother with a separate PR.

@GuySartorelli GuySartorelli force-pushed the pulls/5/new-orm-features branch 2 times, most recently from 3f2912f to 34ed353 Compare September 26, 2023 23:20
@@ -637,29 +637,98 @@ public function countDuplicates($model, $fieldToCheck)
}
```

### Common Table Expressions (CTEs aka the `WITH` clause) {#cte}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm intentionally cramming the common three ways to refer to this functionality into the heading for search discovery purposes:

  • "Common Table Expressions"
  • "CTE"
  • "WITH clause"

Comment on lines +108 to +109
// Combine another query using a union
$sqlQuery->addUnion($anotherSqlSelect, SQLSelect::UNION_ALL);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've intentionally not added any more documentation than this for unions because I think the method is self-explanatory for anyone who knows what a union is and how it's used in SQL.

Frankly, anyone who doesn't understand the SQL concept of unions probably won't care about it anyway or have any reason to use it.

This is also roughly the same amount of documentation available for joins, which are arguably more complex to use as far as the API is concerned.

@GuySartorelli GuySartorelli force-pushed the pulls/5/new-orm-features branch from 34ed353 to 3859d62 Compare September 26, 2023 23:26
@GuySartorelli GuySartorelli marked this pull request as ready for review September 26, 2023 23:27
@emteknetnz
Copy link
Member

I left a review on silverstripe/silverstripe-framework#10943 - depending on that we may want to change stuff in this PR

@GuySartorelli
Copy link
Member Author

Rebased to resolve conflicts

@GuySartorelli GuySartorelli force-pushed the pulls/5/new-orm-features branch from 3859d62 to 02f1b10 Compare September 27, 2023 02:58
@GuySartorelli
Copy link
Member Author

There have been some changes in the code, but I'll hold off updating docs until that PR has been approved.

@GuySartorelli GuySartorelli force-pushed the pulls/5/new-orm-features branch from 02f1b10 to 261a51f Compare October 2, 2023 01:15
@GuySartorelli
Copy link
Member Author

Updated docs to reflect the recent code changes, and to make some things slightly clearer.

@emteknetnz emteknetnz merged commit c6525f2 into silverstripe:5 Oct 2, 2023
@emteknetnz emteknetnz deleted the pulls/5/new-orm-features branch October 2, 2023 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants