Using .Databases with a misspelled database name changes database name in SMO

Aperta
#115 6 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
csharp, powershell
Ambito
databases

Direzione di ricerca

Inizia riproducendo il comportamento con gli esempi PowerShell usando Server.Databases e il relativo indicizzatore di stringhe. Poi segui l’implementazione alla base della ricerca nella raccolta Databases e aggiungi una copertura di regressione per una query con maiuscole e minuscole diverse o con un errore di ortografia. Il lavoro è completato quando interrogare un database non modifica più il nome originale del database né la relativa combinazione di maiuscole e minuscole.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

This bug was found using dbatools: https://github.com/dataplat/dbatools/issues/8598

There are two ways to select a single database from the list of databases from a Microsoft.SqlServer.Management.Smo.Server object: $server.Databases | Where-Object Name -EQ <dbname> and $server['<dbname>'].

The first one works without problems. But the second one changes the casing of the name from the original one to the one used to query the database.

Here is the code to show that:

Import-Module -Name dbatools

# correct:
$server = [Microsoft.SqlServer.Management.Smo.Server]::new('sql01')
$server.Databases | Where-Object Name -EQ Master | Select-Object -ExpandProperty Name
$server.Databases['Master'] | Select-Object -ExpandProperty Name

# wrong:
$server = [Microsoft.SqlServer.Management.Smo.Server]::new('sql01')
$server.Databases['Master'] | Select-Object -ExpandProperty Name
$server.Databases | Where-Object Name -EQ Master | Select-Object -ExpandProperty Name

And here is a screenshot:

image

Yes, I'm using not the current version - but I don't have the current version at hand. But I think it will take you only minutes to test this in your test environment. If it is fixed with the current version: Sorry to bother you.

Lingua principale
C#
Stelle
143
Fork
28
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/sqlmanagementobjects

Tutte le issue di microsoft/sqlmanagementobjects

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.