Skip to content

Commit 607ea87

Browse files
authored
Merge pull request #135 from LowlyDBA/development
Limit stored proc output by default
2 parents 90f961d + abd0bb9 commit 607ea87

File tree

8 files changed

+383
-3574
lines changed

8 files changed

+383
-3574
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<!-- markdownlint-disable-file -->
2+
<!--- Provide a general summary of your changes in the Title above -->
3+
4+
## Description
5+
<!--- Describe your changes in detail -->
6+
7+
## Related Issue
8+
<!--- This project only accepts pull requests related to open issues -->
9+
<!--- If suggesting a new feature or change, please discuss it in an issue first -->
10+
<!--- If fixing a bug, there should be an issue describing it with steps to reproduce -->
11+
<!--- Please link to the issue here: -->
12+
13+
## Motivation and Context
14+
<!--- Why is this change required? What problem does it solve? -->
15+
16+
## How Has This Been Tested?
17+
<!--- Please describe in detail how you tested your changes. -->
18+
<!--- Include details of your testing environment, and the tests you ran to -->
19+
<!--- see how your change affects other areas of the code, etc. -->
20+
21+
## Screenshots (if appropriate):
22+
23+
## Types of changes
24+
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
25+
- [ ] Bug fix (non-breaking change which fixes an issue)
26+
- [ ] New feature (non-breaking change which adds functionality)
27+
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
28+
29+
## Checklist:
30+
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
31+
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
32+
- [ ] My code follows the code style of this project.
33+
- [ ] My change requires a change to the documentation.
34+
- [ ] I have updated the documentation accordingly.
35+
- [ ] I have read the [**CONTRIBUTING**](../CONTRIBUTING.md) document.
36+
- [ ] I have added tests to cover my changes.
37+
- [ ] All new and existing tests passed.

CONTRIBUTING.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Contributing to Express SQL
2+
3+
:wave: Hi there! Thanks for using and contributing to the Express SQL suite of scripts!
4+
5+
Below are guidelines and helpful approaches for participating in the project.
6+
7+
* [How to Help](#how-to-help)
8+
* [Testing](#testing-locally)
9+
* [Style Guide](#style-guide)
10+
11+
## How to Help
12+
13+
You can help contribute by:
14+
15+
* Opening a feature request
16+
* Opening a :bug:
17+
* Increasing unit test coverage
18+
* Making a pull request to address any of the above
19+
20+
## Testing Locally
21+
22+
While Appveyor tests across most modern SQL Server versions for compatibility
23+
and unit tests check basic functionality, there are still parts of the scripts
24+
that benefit from human validation and localized testing scenarios.
25+
26+
If you have multiple versions of SQL Server at your disposal, testing across
27+
them is appreciated.
28+
29+
To run local tests from the root of the repository, use the same
30+
PowerShell scripts used by Appveyor (check appveyor.yml for
31+
examples of how to use each script):
32+
33+
1. If you don't have the PowerShell modules DbaTools and SqlServer (and don't
34+
want to install them manually) you can run `appveyor\install_dependencies.ps1`
35+
to get them in addition to TSQLLint (via npm)
36+
2. If you don't have a [tSQLt][tsqlt] database already, run `appveyor\install_tsqlt.ps1`
37+
to install a local copy of it
38+
3. Install the Express SQL Suite with `appveyor\install_expsql.ps1`
39+
4. Build the unit tests with `appveyor\build_tsqlt_tests.ps1`
40+
5. Make any proposed modifications to the scripts
41+
6. Verify all unit tests pass with `appveyor\run_tsqlt_tests.ps1`
42+
7. If `sp_doc` was changed, visually inspect a generated markdown file
43+
to ensure everything looks as expected (but do not commit it to your branch)
44+
8. Make a pull request! :tada:
45+
46+
## Style Guide
47+
48+
Styles (or lack thereof) that are particular to this project.
49+
Think :tshirt:, not :necktie:
50+
51+
### T-SQL
52+
53+
While there is no hard rule on T-SQL style enforced or linted in this project, use
54+
your discretion to fit the existing style and favor readability over a strict
55+
adherence to a specific style.
56+
57+
### Markdown
58+
59+
All markdown, whether manually or automatically generated, should adhere to standard
60+
markdown rules. This project utilize's David Anson's [markdown lint][mdlint]
61+
with a slightly customized
62+
[configuration][mdconfig].
63+
64+
You can use our config and markdown lint plugins in your IDE of choice, or just wait
65+
for your commits to be automatically linted using Github Actions.
66+
67+
### PowerShell
68+
69+
PowerShell is only used in the automation piece of this project, but could probably
70+
benefit from being better documented and standardized. Right now no particular
71+
style is enforced, but one may be used in the future.
72+
73+
[mdconfig]: https://github.com/LowlyDBA/ExpressSQL/blob/master/.github/linters/.markdown-lint.yml
74+
[mdlint]: https://github.com/DavidAnson/markdownlint
75+
[tsqlt]: https://tsqlt.org/

appveyor/sqlcover/Coverage.opencoverxml

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,31 @@
99
<Summary numSequencePoints="25" visitedSequencePoints="0" numBranchPoints="0" visitedBranchPoints="0" sequenceCoverage="100" branchCoverage="0" maxCyclomaticComplexity="0" minCyclomaticComplexity="0" />
1010
<MetadataToken>01041980</MetadataToken><Name>[dbo].[sp_doc]</Name><FileRef uid="1" />
1111
<SequencePoints>
12-
<SequencePoint vc="7" uspid="1" ordinal="1" offset="1633" sl="43" sc="1" el="43" ec="15" />
13-
<SequencePoint vc="7" uspid="2" ordinal="2" offset="1841" sl="53" sc="1" el="53" ec="26" />
14-
<SequencePoint vc="5" uspid="3" ordinal="3" offset="1881" sl="55" sc="3" el="55" ec="80" />
15-
<SequencePoint vc="7" uspid="4" ordinal="4" offset="1970" sl="57" sc="1" el="57" ec="26" />
16-
<SequencePoint vc="7" uspid="5" ordinal="5" offset="2010" sl="59" sc="3" el="59" ec="80" />
17-
<SequencePoint vc="7" uspid="6" ordinal="6" offset="2123" sl="63" sc="1" el="63" ec="27" />
18-
<SequencePoint vc="1" uspid="7" ordinal="7" offset="2164" sl="65" sc="3" el="65" ec="72" />
19-
<SequencePoint vc="1" uspid="8" ordinal="8" offset="2239" sl="66" sc="3" el="66" ec="25" />
20-
<SequencePoint vc="6" uspid="9" ordinal="9" offset="2299" sl="70" sc="1" el="70" ec="27" />
21-
<SequencePoint vc="4" uspid="10" ordinal="10" offset="2339" sl="72" sc="3" el="72" ec="32" />
22-
<SequencePoint vc="2" uspid="11" ordinal="11" offset="2384" sl="74" sc="6" el="74" ec="39" />
23-
<SequencePoint vc="1" uspid="12" ordinal="12" offset="2432" sl="76" sc="3" el="76" ec="39" />
24-
<SequencePoint vc="1" uspid="13" ordinal="13" offset="2474" sl="77" sc="3" el="77" ec="25" />
25-
<SequencePoint vc="5" uspid="14" ordinal="14" offset="2510" sl="80" sc="1" el="80" ec="51" />
26-
<SequencePoint vc="5" uspid="15" ordinal="15" offset="2618" sl="83" sc="1" el="86" ec="28" />
27-
<SequencePoint vc="5" uspid="16" ordinal="16" offset="2843" sl="91" sc="1" el="107" ec="29" />
28-
<SequencePoint vc="5" uspid="17" ordinal="17" offset="3487" sl="113" sc="1" el="323" ec="6" />
29-
<SequencePoint vc="5" uspid="18" ordinal="18" offset="11956" sl="329" sc="1" el="450" ec="6" />
30-
<SequencePoint vc="5" uspid="19" ordinal="19" offset="16881" sl="456" sc="1" el="576" ec="6" />
31-
<SequencePoint vc="5" uspid="20" ordinal="20" offset="21913" sl="582" sc="1" el="705" ec="6" />
32-
<SequencePoint vc="5" uspid="21" ordinal="21" offset="27028" sl="711" sc="1" el="830" ec="6" />
33-
<SequencePoint vc="5" uspid="22" ordinal="22" offset="32078" sl="836" sc="1" el="910" ec="52" />
34-
<SequencePoint vc="5" uspid="23" ordinal="23" offset="35113" sl="913" sc="1" el="916" ec="20" />
35-
<SequencePoint vc="5" uspid="24" ordinal="24" offset="35195" sl="918" sc="1" el="918" ec="78" />
36-
<SequencePoint vc="5" uspid="25" ordinal="25" offset="35276" sl="919" sc="1" el="922" ec="16" />
12+
<SequencePoint vc="7" uspid="1" ordinal="1" offset="1667" sl="44" sc="1" el="44" ec="15" />
13+
<SequencePoint vc="7" uspid="2" ordinal="2" offset="1875" sl="54" sc="1" el="54" ec="26" />
14+
<SequencePoint vc="5" uspid="3" ordinal="3" offset="1915" sl="56" sc="3" el="56" ec="80" />
15+
<SequencePoint vc="7" uspid="4" ordinal="4" offset="2004" sl="58" sc="1" el="58" ec="26" />
16+
<SequencePoint vc="7" uspid="5" ordinal="5" offset="2044" sl="60" sc="3" el="60" ec="80" />
17+
<SequencePoint vc="7" uspid="6" ordinal="6" offset="2157" sl="64" sc="1" el="64" ec="27" />
18+
<SequencePoint vc="1" uspid="7" ordinal="7" offset="2198" sl="66" sc="3" el="66" ec="72" />
19+
<SequencePoint vc="1" uspid="8" ordinal="8" offset="2273" sl="67" sc="3" el="67" ec="25" />
20+
<SequencePoint vc="6" uspid="9" ordinal="9" offset="2333" sl="71" sc="1" el="71" ec="27" />
21+
<SequencePoint vc="4" uspid="10" ordinal="10" offset="2373" sl="73" sc="3" el="73" ec="32" />
22+
<SequencePoint vc="2" uspid="11" ordinal="11" offset="2418" sl="75" sc="6" el="75" ec="39" />
23+
<SequencePoint vc="1" uspid="12" ordinal="12" offset="2466" sl="77" sc="3" el="77" ec="39" />
24+
<SequencePoint vc="1" uspid="13" ordinal="13" offset="2508" sl="78" sc="3" el="78" ec="25" />
25+
<SequencePoint vc="5" uspid="14" ordinal="14" offset="2544" sl="81" sc="1" el="81" ec="51" />
26+
<SequencePoint vc="5" uspid="15" ordinal="15" offset="2652" sl="84" sc="1" el="87" ec="28" />
27+
<SequencePoint vc="5" uspid="16" ordinal="16" offset="2877" sl="92" sc="1" el="108" ec="29" />
28+
<SequencePoint vc="5" uspid="17" ordinal="17" offset="3521" sl="114" sc="1" el="324" ec="6" />
29+
<SequencePoint vc="5" uspid="18" ordinal="18" offset="11990" sl="330" sc="1" el="451" ec="6" />
30+
<SequencePoint vc="5" uspid="19" ordinal="19" offset="16922" sl="457" sc="1" el="591" ec="6" />
31+
<SequencePoint vc="5" uspid="20" ordinal="20" offset="22623" sl="597" sc="1" el="720" ec="6" />
32+
<SequencePoint vc="5" uspid="21" ordinal="21" offset="27738" sl="726" sc="1" el="845" ec="6" />
33+
<SequencePoint vc="5" uspid="22" ordinal="22" offset="32788" sl="851" sc="1" el="925" ec="52" />
34+
<SequencePoint vc="5" uspid="23" ordinal="23" offset="35823" sl="928" sc="1" el="931" ec="20" />
35+
<SequencePoint vc="5" uspid="24" ordinal="24" offset="35905" sl="933" sc="1" el="933" ec="106" />
36+
<SequencePoint vc="5" uspid="25" ordinal="25" offset="36014" sl="934" sc="1" el="938" ec="25" />
3737
</SequencePoints>
3838
</Method>
3939
</Methods>

appveyor/sqlcover/[dbo].[sp_doc]

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
CREATE PROCEDURE [dbo].[sp_doc]
33
@DatabaseName SYSNAME = NULL
44
,@ExtendedPropertyName SYSNAME = 'Description'
5+
,@LimitStoredProcLength BIT = 1
56
/* Parameters defined here for testing only */
67
,@SqlMajorVersion TINYINT = 0
78
,@SqlMinorVersion SMALLINT = 0
@@ -46,7 +47,7 @@ BEGIN
4647
,@ParmDefinition NVARCHAR(500)
4748
,@QuotedDatabaseName SYSNAME
4849
,@Msg NVARCHAR(MAX)
49-
,@LastUpdated NVARCHAR(20) = '2020-09-18';
50+
,@LastUpdated NVARCHAR(20) = '2020-09-22';
5051

5152

5253
-- Find Version
@@ -450,7 +451,7 @@ BEGIN
450451
END;'; --End markdown for views
451452

452453
/***********************
453-
Generate markdown for procedures
454+
Generate markdown for stored procedures
454455
************************/
455456
--Build table of contents
456457
SET @Sql = @Sql + N'
@@ -554,10 +555,24 @@ BEGIN
554555
,(CONCAT(CHAR(13), CHAR(10), ''<details><summary>Click to expand</summary>''));' +
555556

556557
--Object definition
557-
+ N'INSERT INTO #markdown (value)
558-
VALUES (CONCAT(CHAR(13), CHAR(10), ''```sql'',
559-
CHAR(13), CHAR(10), OBJECT_DEFINITION(@objectid)))
560-
,(''```'');' +
558+
+ N'
559+
IF (@LimitStoredProcLength = 1 AND LEN(OBJECT_DEFINITION(@objectid)) > 8000)
560+
BEGIN;
561+
INSERT INTO #markdown (value)
562+
VALUES (CONCAT(CHAR(13), CHAR(10), ''```sql'',
563+
CHAR(13), CHAR(10), CAST(OBJECT_DEFINITION(@objectid) AS VARCHAR(8000))))
564+
,(''/************************************************************************************************/'')
565+
,(''/* sp_doc: Max 8000 characters reached. Set @LimitStoredProcLength = 0 to show full definition. */'')
566+
,(''/************************************************************************************************/'')
567+
,(''```'');
568+
END;
569+
ELSE
570+
BEGIN;
571+
INSERT INTO #markdown (value)
572+
VALUES (CONCAT(CHAR(13), CHAR(10), ''```sql'',
573+
CHAR(13), CHAR(10), OBJECT_DEFINITION(@objectid)))
574+
,(''```'');
575+
END;' +
561576

562577
--Back to top
563578
+ N'INSERT INTO #markdown
@@ -915,11 +930,12 @@ BEGIN
915930
FROM #markdown
916931
ORDER BY [ID] ASC;';
917932

918-
SET @ParmDefinition = N'@ExtendedPropertyName SYSNAME, @DatabaseName SYSNAME';
933+
SET @ParmDefinition = N'@ExtendedPropertyName SYSNAME, @DatabaseName SYSNAME, @LimitStoredProcLength BIT';
919934
EXEC sp_executesql @Sql
920935
,@ParmDefinition
921936
,@ExtendedPropertyName
922-
,@DatabaseName;
937+
,@DatabaseName
938+
,@LimitStoredProcLength;
923939
END;
924940

925941

0 commit comments

Comments
 (0)