Skip to content

Commit

Permalink
v1.8.0 - BulkCopy Notification Enhancements (#43)
Browse files Browse the repository at this point in the history
* adding gitignore
* setting version
* updated batchsize max to 25k; added NotifyAction parameter
* added -NotifyAction
* Version History Updates
* pester test updates for pester v5
  • Loading branch information
mithrandyr authored Apr 2, 2021
1 parent ddcb48c commit 5882774
Show file tree
Hide file tree
Showing 7 changed files with 308 additions and 40 deletions.
269 changes: 269 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,269 @@
/output/
/binarysrc/packages/*
#packages/
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/

# Visual Studio 2015/2017 cache/options directory
.vs/

# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/

# StyleCop
StyleCopReport.xml

# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc

# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap

# Visual Studio Trace Files
*.e2e

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user

# Visual Studio code coverage results
*.coverage
*.coveragexml

# Click-Once directory
publish/

# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj

# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets

# Microsoft Azure Build Output
csx/
*.build.csdef

# Microsoft Azure Emulator
ecf/
rcf/

# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload

# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/

# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs

# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk

# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak

# SQL Server files
*.mdf
*.ldf
*.ndf

# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl

# Microsoft Fakes
FakesAssemblies/

# GhostDoc plugin setting file
*.GhostDoc.xml

# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/

# Visual Studio 6 build log
*.plg

# Visual Studio 6 workspace options file
*.opt

# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw

# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions

# Paket dependency manager
.paket/paket.exe
paket-files/

# FAKE - F# Make
.fake/

# CodeRush personal settings
.cr/personal

# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc

# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config

# Tabs Studio
*.tss

# Telerik's JustMock configuration file
*.jmconfig

# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs

# OpenCover UI analysis results
OpenCover/

# Azure Stream Analytics local run output
ASALocalRun/

# MSBuild Binary and Structured Log
*.binlog

# NVidia Nsight GPU debugger configuration file
*.nvuser

# MFractors (Xamarin productivity tool) working folder
.mfractor/

# Local History for Visual Studio
.localhistory/

# BeatPulse healthcheck temp database
healthchecksdb

# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/

# Fody - auto-generated XML schema
FodyWeavers.xsd
44 changes: 22 additions & 22 deletions PesterTests/mysql.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,39 @@
#>
InModuleScope SimplySql {
Describe "MySql" {
BeforeEach { Open-MySqlConnection -Database sys -Credential ([pscredential]::new("root", (ConvertTo-SecureString -Force -AsPlainText "password"))) }
BeforeEach { Open-MySqlConnection -Database mysql -Credential ([pscredential]::new("root", (ConvertTo-SecureString -Force -AsPlainText "root"))) }
AfterEach { Show-SqlConnection -all | Close-SqlConnection }

It "Test ConnectionString Switch " {
{
Open-MySqlConnection -ConnectionString "server=localhost;database=sys;port=3306;user id=root;password=password;useaffectedrows=True;allowuservariables=True;sslmode=none" -ConnectionName Test
Open-MySqlConnection -ConnectionString "server=localhost;database=mysql;port=3306;user id=root;password=root;useaffectedrows=True;allowuservariables=True;sslmode=none" -ConnectionName Test
Close-SqlConnection -ConnectionName Test
} | Should -Not -Throw
}

It "Test UserName/Password Parameters" {
{
Open-MySqlConnection -UserName root -Password password -Database sys -ConnectionName test
Open-MySqlConnection -UserName root -Password root -Database mysql -ConnectionName test
Close-SqlConnection -ConnectionName test
} | Should -Not -Throw
}

It "Creating Views" {
Invoke-SqlUpdate -Query "CREATE OR REPLACE VIEW sys.generator_16
Invoke-SqlUpdate -Query "CREATE OR REPLACE VIEW mysql.generator_16
AS SELECT 0 n UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL
SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL
SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL
SELECT 9 UNION ALL SELECT 10 UNION ALL SELECT 11 UNION ALL
SELECT 12 UNION ALL SELECT 13 UNION ALL SELECT 14 UNION ALL
SELECT 15;
CREATE OR REPLACE VIEW sys.generator_256
CREATE OR REPLACE VIEW mysql.generator_256
AS SELECT ( ( hi.n << 4 ) | lo.n ) AS n
FROM sys.generator_16 lo, sys.generator_16 hi;
FROM mysql.generator_16 lo, mysql.generator_16 hi;
CREATE OR REPLACE VIEW sys.generator_64k
CREATE OR REPLACE VIEW mysql.generator_64k
AS SELECT ( ( hi.n << 8 ) | lo.n ) AS n
FROM sys.generator_256 lo, sys.generator_256 hi;" | Out-Null
FROM mysql.generator_256 lo, mysql.generator_256 hi;" | Out-Null
1 | Should -Be 1
}

Expand All @@ -54,12 +54,12 @@ InModuleScope SimplySql {

It "Invoke-SqlUpdate" {
Invoke-SqlUpdate -Query "
CREATE TABLE sys.tmpTable (colDec REAL, colInt Int, colText varchar(36));
INSERT INTO sys.tmpTable
CREATE TABLE mysql.tmpTable (colDec REAL, colInt Int, colText varchar(36));
INSERT INTO mysql.tmpTable
SELECT rand() AS colDec
, CAST(rand() * 1000000000 AS SIGNED) AS colInt
, uuid() AS colText
FROM sys.generator_64k" | Should -Be 65536
FROM mysql.generator_64k" | Should -Be 65536

}

Expand All @@ -68,7 +68,7 @@ InModuleScope SimplySql {
SELECT rand() AS colDec
, CAST(rand() * 1000000000 AS SIGNED) AS colInt
, uuid() AS colText
FROM sys.generator_64k
FROM mysql.generator_64k
LIMIT 1000" |
Measure-Object |
Select-Object -ExpandProperty Count |
Expand All @@ -80,7 +80,7 @@ InModuleScope SimplySql {
SELECT rand() AS colDec
, CAST(rand() * 1000000000 AS SIGNED) AS colInt
, uuid() AS colText
FROM sys.generator_64k
FROM mysql.generator_64k
LIMIT 1000" -Stream |
Measure-Object |
Select-Object -ExpandProperty Count |
Expand All @@ -91,12 +91,12 @@ InModuleScope SimplySql {
$query = "SELECT rand() AS colDec
, CAST(rand() * 1000000000 AS SIGNED) AS colInt
, uuid() AS colText
FROM sys.generator_64k"
FROM mysql.generator_64k"

Open-MySqlConnection -ConnectionName bcp -Database sys -Credential ([pscredential]::new("root", (ConvertTo-SecureString -Force -AsPlainText "password")))
Invoke-SqlUpdate -ConnectionName bcp -Query "CREATE TABLE sys.tmpTable2 (colDec REAL, colInt INTEGER, colText TEXT)"
Open-MySqlConnection -ConnectionName bcp -Database mysql -Credential ([pscredential]::new("root", (ConvertTo-SecureString -Force -AsPlainText "root")))
Invoke-SqlUpdate -ConnectionName bcp -Query "CREATE TABLE mysql.tmpTable2 (colDec REAL, colInt INTEGER, colText TEXT)"

Invoke-SqlBulkCopy -DestinationConnectionName bcp -SourceQuery $query -DestinationTable "sys.tmpTable2" -Notify |
Invoke-SqlBulkCopy -DestinationConnectionName bcp -SourceQuery $query -DestinationTable "mysql.tmpTable2" -Notify |
Should -Be 65536

Close-SqlConnection -ConnectionName bcp
Expand Down Expand Up @@ -125,11 +125,11 @@ InModuleScope SimplySql {

It "Dropping Tables, Views" {
Try { Invoke-SqlUpdate "DROP TABLE transactionTest" | Out-Null } Catch {}
Try { Invoke-SqlUpdate "DROP TABLE sys.tmpTable" | Out-Null } Catch {}
Try { Invoke-SqlUpdate "DROP TABLE sys.tmpTable2" | Out-Null } Catch {}
Try { Invoke-SqlUpdate "DROP VIEW sys.generator_64k" | Out-Null } Catch {}
Try { Invoke-SqlUpdate "DROP VIEW sys.generator_256" | Out-Null } Catch {}
Try { Invoke-SqlUpdate "DROP VIEW sys.generator_16" | Out-Null } Catch {}
Try { Invoke-SqlUpdate "DROP TABLE mysql.tmpTable" | Out-Null } Catch {}
Try { Invoke-SqlUpdate "DROP TABLE mysql.tmpTable2" | Out-Null } Catch {}
Try { Invoke-SqlUpdate "DROP VIEW mysql.generator_64k" | Out-Null } Catch {}
Try { Invoke-SqlUpdate "DROP VIEW mysql.generator_256" | Out-Null } Catch {}
Try { Invoke-SqlUpdate "DROP VIEW mysql.generator_16" | Out-Null } Catch {}
1 | Should -Be 1
}
}
Expand Down
Loading

0 comments on commit 5882774

Please sign in to comment.