enable table designer for table script in sql database project (#19237)

* add 'open in designer' to context menu of tables in sql projects

* fix tests

* Address comments

* enable table designer for sql database proj

* update label and issues on init

* vbump sts

* use promisified fs

* pr comments

Co-authored-by: Alan Ren <alanren@microsoft.com>
This commit is contained in:
Kim Santiago
2022-06-02 10:27:47 -10:00
committed by GitHub
parent d3c474162d
commit 1bbf5a78c1
16 changed files with 219 additions and 118 deletions

View File

@@ -245,10 +245,20 @@ export class Project implements ISqlProject {
// create a FileProjectEntry for each file
const fileEntries: FileProjectEntry[] = [];
filesSet.forEach(f => {
for (let f of Array.from(filesSet.values())) {
const typeEntry = entriesWithType.find(e => e.relativePath === f);
fileEntries.push(this.createFileProjectEntry(f, EntryType.File, typeEntry ? typeEntry.typeAttribute : undefined));
});
let containsCreateTableStatement;
// read file to check if it has a "Create Table" statement
const fullPath = path.join(utils.getPlatformSafeFileEntryPath(this.projectFolderPath), utils.getPlatformSafeFileEntryPath(f));
if (await utils.exists(fullPath)) {
const fileContents = await fs.readFile(fullPath);
containsCreateTableStatement = fileContents.toString().toLowerCase().includes('create table');
}
fileEntries.push(this.createFileProjectEntry(f, EntryType.File, typeEntry ? typeEntry.typeAttribute : undefined, containsCreateTableStatement));
}
return fileEntries;
}
@@ -1078,13 +1088,14 @@ export class Project implements ISqlProject {
return this.getCollectionProjectPropertyValue(constants.DatabaseSource);
}
public createFileProjectEntry(relativePath: string, entryType: EntryType, sqlObjectType?: string): FileProjectEntry {
public createFileProjectEntry(relativePath: string, entryType: EntryType, sqlObjectType?: string, containsCreateTableStatement?: boolean): FileProjectEntry {
let platformSafeRelativePath = utils.getPlatformSafeFileEntryPath(relativePath);
return new FileProjectEntry(
Uri.file(path.join(this.projectFolderPath, platformSafeRelativePath)),
utils.convertSlashesForSqlProj(relativePath),
entryType,
sqlObjectType);
sqlObjectType,
containsCreateTableStatement);
}
private findOrCreateItemGroup(containedTag?: string, prePostScriptExist?: { scriptExist: boolean; }): Element {