mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-22 17:22:59 -05:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user