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

[Bug] Export-DbaScript return 2 spaces if object doesn't exist #5418

Closed
2 of 3 tasks
asnest opened this issue Apr 26, 2019 · 4 comments
Closed
2 of 3 tasks

[Bug] Export-DbaScript return 2 spaces if object doesn't exist #5418

asnest opened this issue Apr 26, 2019 · 4 comments

Comments

@asnest
Copy link

asnest commented Apr 26, 2019

Before submitting a bug report:

  • Running latest release of dbatools
  • Verified errors are not related to permissions
  • Is this bug with Copy-DbaDatabase? You can replicate it using Backup-DbaDatabase ... | Restore-DbaDatabase ...

NOTE: Copy-DbaDatabase will not work in every environment and every situation. Instead, we try to ensure Backup & Restore work in your environment.

Environmental data

### PowerShell version:

Name                           Value
----                           -----
PSVersion                      5.1.14393.2879
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.2879
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1




### dbatools Module version:


Name    : dbatools
Path    : C:\Program Files\WindowsPowerShell\Modules\dbatools\0.9.811\dbatools.psd1
Version : 0.9.811

SQL Server:

Microsoft SQL Server 2016 (RTM-GDR) (KB4019088) - 13.0.1742.0 (X64)   Jul  5 2017 23:41:17   Copyright (c) Microsoft Corporation  Enterprise Edition: Core-based Licensing (64-bit) on Windows Server 2016 Datacenter 6.3 <X64> (Build 14393: ) 

Errors Received

no errors

Steps to Reproduce

/*
    Any T-SQL commands involved or used to produce test objects/data.
*/
$options = New-DbaScriptingOption
$options.IncludeIfNotExists = $true
$options.PrimaryObject = $false
$options.DriChecks = $true
$options.DriForeignKeys = $true
$options.DriWithNoCheck = $true
foreach ($Table in Get-DbaDbTable -ServerInstance $server -Database $database)
{if ($Table.name -NotLike 'MS*')
{$Table | Export-DbaScript -Path objects.sql -ScriptingOptionsObject $options -NoPrefix -Append}
}

Expected Behavior

creating object script on each row in file

Actual Behavior

if some tables don't have objects I want to script, function return 2 spaces. And file becomes look like zebra - code, some pages with spaces, code again

@potatoqualitee
Copy link
Member

thanks for the report, we'll take a look when we have a moment

@sqllensman sqllensman self-assigned this Apr 28, 2019
@sqllensman
Copy link
Contributor

Issue was being caused by using a default value for the Prefix of "" even when -NoPrefix is specified.

Will submit fix along with some other updates to Export scripting functions

@potatoqualitee
Copy link
Member

awesome! very much appreciated, @sqllensman

potatoqualitee added a commit that referenced this issue May 28, 2019
@potatoqualitee
Copy link
Member

this will be resolved in dbatools 1.0, due in 20 days👍

potatoqualitee added a commit that referenced this issue May 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants